pub enum DiagnosticCode {
Show 35 variants
SyntaxError,
ParamTypeCheck,
AssignTypeCheck,
UndefinedField,
UndefinedName,
Redefinition,
Unused,
UnnecessaryBranch,
ArgumentCount,
ReturnTypeMismatch,
MacroRedefined,
ConceptNotSatisfied,
IncludeNotFound,
MissingInclude,
AccessInvisible,
MissingReturn,
AssignmentInCondition,
ModuleNote,
BracesAroundStatements,
UseNullptr,
UseOverride,
SimplifyBooleanExpr,
ElseAfterReturn,
CStyleCast,
UseAuto,
MacroParentheses,
ImplicitBoolConversion,
DanglingReturn,
DanglingField,
UseAfterFree,
UeNaming,
UeGenerateBody,
UeGeneratedHeader,
UeMacroScope,
UeSpecifier,
}Expand description
One rule this analysis has.
See the module documentation for the three spellings of a rule and for why the code is derived.
Variants§
SyntaxError
The file does not parse — see super::syntax_error.
ParamTypeCheck
An argument’s type does not convert to the parameter it is passed for — see super::param_type_check.
AssignTypeCheck
A value does not convert to the type it is assigned to or initialised as — see super::assign_type_check.
UndefinedField
A member access on a type that does not declare that member — see super::undefined_field.
UndefinedName
A name nothing declares is read at this position — see super::undefined_name.
Redefinition
A name declared twice in one scope, where the language has no reading for it — see
super::redefinition.
Unused
A declaration nothing uses — see super::unused.
UnnecessaryBranch
A branch the program cannot take, or a condition that is already decided — see
super::unnecessary_branch.
ArgumentCount
More arguments than the callee takes, or fewer than it needs — see super::argument_count.
ReturnTypeMismatch
A return whose expression does not convert to the function’s return type — see
super::return_type_mismatch.
MacroRedefined
A macro defined twice with different replacement lists — see super::macro_redefined.
ConceptNotSatisfied
An argument whose type does not satisfy the concept constraining its parameter — see
super::concept_not_satisfied.
IncludeNotFound
A #include that names a file nobody can find — see super::include_not_found.
Separate from DiagnosticCode::SyntaxError for the reason a reader needs it separate: the file parses
perfectly, and what is missing is a file it named.
MissingInclude
A type this file uses but does not include or import — see [super::missing_include].
The finding a reader turns into a fix: Widget w; compiles only because something upstream happened to include
widget.h, and the file should say so itself. The rule never names the standard library — see the module.
AccessInvisible
A member reached from somewhere that may not reach it - see super::access_invisible.
MissingReturn
A function declared to return something whose body never returns - see super::missing_return.
AssignmentInCondition
= where the reader almost certainly meant == - see super::assignment_in_condition.
ModuleNote
A note about a module import, which the analysis knows rather than complains about — see
Session::notes_about_the_modules.
Not a check: nothing is wrong with the file, and the reader is told where a file they named is. It is a code because it is a diagnostic a client shows, and the point of the enum is that everything shown has one.
BracesAroundStatements
if (x) / for (…) / while (…) whose body is a single statement — see [super::braces_around_statements].
UseNullptr
NULL where nullptr is meant — see [super::use_nullptr].
UseOverride
A virtual member function that overrides without saying override — see [super::use_override].
SimplifyBooleanExpr
if (x == true) and its siblings — see [super::simplify_boolean_expr].
ElseAfterReturn
An else after a branch that returns — see [super::else_after_return].
CStyleCast
A C-style cast — see [super::cstyle_cast].
UseAuto
An iterator declared by its full spelling — see [super::use_auto].
MacroParentheses
A macro body that needs its own parentheses — see [super::macro_parentheses].
ImplicitBoolConversion
A non-boolean value used as a condition — see [super::implicit_bool_conversion].
DanglingReturn
A reference, pointer or view of something that dies when the function returns — see
[super::dangling_return].
DanglingField
A view, reference or pointer member that borrows something which does not outlive the object — see
[super::dangling_field].
UseAfterFree
A pointer read after the memory it refers to was freed — see [super::use_after_free].
UeNaming
A type declared with Unreal Engine’s UCLASS/USTRUCT/UENUM and a name missing the prefix the engine
requires — see [super::ue_naming].
UeGenerateBody
A UCLASS/USTRUCT whose body writes no GENERATED_BODY() — see [super::ue_generate_body].
UeGeneratedHeader
A file with reflection annotations and no *.generated.h include, or one that is not the last include — see
[super::ue_generated_header].
UeMacroScope
A UPROPERTY/UFUNCTION on something the build tool does not reflect — see [super::ue_macro_scope].
UeSpecifier
A reflection specifier the engine does not know, which the build tool silently ignores — see
[super::ue_specifier].
Implementations§
Source§impl DiagnosticCode
impl DiagnosticCode
Sourcepub const ALL: [DiagnosticCode; 35]
pub const ALL: [DiagnosticCode; 35]
Every code, in the order a list reads in.
The order is the one the module documentation of super describes: what the text is (the parse), then
what it says about types, then what it says about a whole body, then the two that are about the reading
rather than the program. A consumer that shows a settings screen, or a test that asserts every rule has a
name and a module, iterates this.
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
The code a client is shown, and the spelling a config file uses: kebab case, and the module’s file name
is the snake-case form of it (param-type-check ↔ param_type_check.rs).
The match has no _ arm on purpose. A new variant without a name is a compile error, which is the only
way to be sure that no rule ever reaches a client unnamed.
Sourcepub fn from_name(name: &str) -> Option<DiagnosticCode>
pub fn from_name(name: &str) -> Option<DiagnosticCode>
The code as a rule, or None for a code this build does not have.
The inverse of DiagnosticCode::name, and the round trip is asserted for every variant. A config reader
uses this so that a misspelled rule is reported — treating an unknown name as “no rules” turns a typo into
a silently disabled analysis, which is the failure mode this layer’s contract is written against.
Sourcepub fn severity(self) -> RuleSeverity
pub fn severity(self) -> RuleSeverity
How a client should draw it.
This crate does not speak LSP — the severities are its own, and the server maps them — for the reason it does not speak LSP anywhere else: the analysis is usable by a batch tool that has no protocol at all.
What a client may grey out — the protocol’s DiagnosticTag, as this crate’s own vocabulary.
A tag is not a severity: a warning can be tagged Unnecessary and so can a hint. It says why the reader
is being told, which is what a client needs to render the code as struck through rather than merely
underlined — the difference between “look at this” and “this does nothing”.
Per code rather than per finding, for the same reason severity is: “nothing uses this name” is what the rule says, and it says it about every finding it produces.
Sourcepub fn is_a_complaint(self) -> bool
pub fn is_a_complaint(self) -> bool
Is this code a claim that something is wrong, as opposed to something the reader is told?
DiagnosticCode::ModuleNote is the only one that is not, and the distinction is the one the diagnostics
channel already makes: a note draws no squiggle and does not count towards “this file has problems”.
Sourcepub fn is_cpp_only(self) -> bool
pub fn is_cpp_only(self) -> bool
Is this rule about C++ only? — the question a C project’s diagnostics turn on.
Two kinds of code answer yes, and they are one answer for the same reason: a rule that names C++ grammar cannot
fire in a C file, and a rule that names C++ style must not. cstyle-cast is the second kind — in C, a C-style
cast is the only cast there is, so telling a C program to write static_cast is telling it to write C++.
use-nullptr is the same: NULL is what C has, and C23’s nullptr is a different question from the modernise
one. implicit-bool-conversion belongs here too, because an int in a condition is the language’s own idiom in
C, and a reader who turns this server on for a C project asked for C to be read rather than rewritten.
Measured before this existed: a C corpus configured with -std=c17 answered 14 cstyle-cast findings
telling the program to write static_cast, and the same shape of noise was available to every rule below.
A project that states no language gets all of them: “not told” is not “C”, and a feature disappearing without a word is worse than a finding a project can switch off.
Sourcepub fn is_unreal_only(self) -> bool
pub fn is_unreal_only(self) -> bool
Does this rule only make sense in Unreal Engine code? — the switch [unreal] enable turns.
The two answers are one kind: ue-naming and ue-generate-body name conventions and macros of that engine, and
a project that never writes UCLASS() has nothing for them to say. Like DiagnosticCode::is_cpp_only, “not
told” is not the answer either way — a project that does not say it is Unreal is not treated as one.
Trait Implementations§
Source§impl Clone for DiagnosticCode
impl Clone for DiagnosticCode
impl Copy for DiagnosticCode
Source§impl Debug for DiagnosticCode
impl Debug for DiagnosticCode
impl Eq for DiagnosticCode
Source§impl Hash for DiagnosticCode
impl Hash for DiagnosticCode
Source§impl Ord for DiagnosticCode
impl Ord for DiagnosticCode
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for DiagnosticCode
impl PartialEq for DiagnosticCode
Source§impl PartialOrd for DiagnosticCode
impl PartialOrd for DiagnosticCode
impl StructuralPartialEq for DiagnosticCode
Auto Trait Implementations§
impl Forget for DiagnosticCode
impl Freeze for DiagnosticCode
impl RefUnwindSafe for DiagnosticCode
impl Send for DiagnosticCode
impl Sync for DiagnosticCode
impl Unpin for DiagnosticCode
impl UnsafeUnpin for DiagnosticCode
impl UnwindSafe for DiagnosticCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more