Skip to main content

mir_issues/
psalm_levels.rs

1//! Psalm's per-issue `ERROR_LEVEL` for the issue kinds mir shares with it.
2//! Kinds absent from the table (always-error, opt-in feature, or mir-only) are unaffected by the level.
3
4/// Psalm error level (1–8) at which `name` stops being reported as an error.
5/// An issue is downgraded to info when the configured level is above this value.
6pub fn psalm_error_level(name: &str) -> Option<u8> {
7    Some(match name {
8        "MixedArgument"
9        | "MixedArrayAccess"
10        | "MixedArrayOffset"
11        | "MixedAssignment"
12        | "MixedClone"
13        | "MixedFunctionCall"
14        | "MixedMethodCall"
15        | "MixedPropertyAssignment"
16        | "MixedPropertyFetch"
17        | "MixedReturnStatement"
18        | "PossiblyNullOperand"
19        | "Trace" => 1,
20        "DeprecatedCall"
21        | "DeprecatedClass"
22        | "DeprecatedConstant"
23        | "DeprecatedInterface"
24        | "DeprecatedMethod"
25        | "DeprecatedMethodCall"
26        | "DeprecatedProperty"
27        | "DeprecatedTrait"
28        | "DirectConstructorCall"
29        | "DocblockTypeContradiction"
30        | "InvalidStringClass"
31        | "MissingClosureReturnType"
32        | "MissingConstructor"
33        | "MissingParamType"
34        | "MissingPropertyType"
35        | "MissingReturnType"
36        | "RawObjectIteration"
37        | "UnsupportedReferenceUsage" => 2,
38        "ArgumentTypeCoercion"
39        | "PossiblyInvalidArgument"
40        | "PossiblyInvalidArrayAccess"
41        | "PossiblyInvalidArrayOffset"
42        | "PossiblyInvalidClone"
43        | "PossiblyInvalidOperand"
44        | "PossiblyNullArgument"
45        | "PossiblyNullArrayAccess"
46        | "PossiblyNullMethodCall"
47        | "PossiblyNullPropertyFetch"
48        | "PossiblyUndefinedVariable"
49        | "PropertyTypeCoercion" => 3,
50        "ForbiddenCode"
51        | "IfThisIsMismatch"
52        | "ImplicitToStringCast"
53        | "InternalMethod"
54        | "InvalidDocblock"
55        | "InvalidDocblockType"
56        | "InvalidOperand"
57        | "InvalidToString"
58        | "MismatchingDocblockParamType"
59        | "MismatchingDocblockReturnType"
60        | "NoInterfaceProperties"
61        | "RedundantCast"
62        | "RedundantCondition"
63        | "TooManyArguments"
64        | "TypeDoesNotContainType" => 4,
65        "NullableReturnStatement" => 5,
66        "InvalidArgument"
67        | "InvalidArrayAccess"
68        | "InvalidArrayAssignment"
69        | "InvalidArrayOffset"
70        | "InvalidCast"
71        | "InvalidCatch"
72        | "InvalidClone"
73        | "InvalidNamedArgument"
74        | "InvalidPropertyAssignment"
75        | "InvalidPropertyFetch"
76        | "InvalidReturnType"
77        | "InvalidTemplateParam"
78        | "NullArgument"
79        | "UndefinedMethod"
80        | "UndefinedProperty" => 6,
81        "AbstractInstantiation"
82        | "InvalidOverride"
83        | "MethodSignatureMismatch"
84        | "OverriddenMethodAccess"
85        | "UnhandledMatchCondition" => 7,
86        _ => return None,
87    })
88}