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        | "PossiblyUndefinedMethod"
49        | "PossiblyUndefinedVariable"
50        | "PropertyTypeCoercion" => 3,
51        "ForbiddenCode"
52        | "IfThisIsMismatch"
53        | "ImplicitToStringCast"
54        | "InternalMethod"
55        | "InvalidDocblock"
56        | "InvalidDocblockType"
57        | "InvalidOperand"
58        | "InvalidToString"
59        | "MismatchingDocblockParamType"
60        | "MismatchingDocblockReturnType"
61        | "NoInterfaceProperties"
62        | "RedundantCast"
63        | "RedundantCondition"
64        | "TooManyArguments"
65        | "TypeDoesNotContainType" => 4,
66        "NullableReturnStatement" => 5,
67        "InvalidArgument"
68        | "InvalidArrayAccess"
69        | "InvalidArrayAssignment"
70        | "InvalidArrayOffset"
71        | "InvalidCast"
72        | "InvalidCatch"
73        | "InvalidClone"
74        | "InvalidNamedArgument"
75        | "InvalidPropertyAssignment"
76        | "InvalidPropertyFetch"
77        | "InvalidReturnType"
78        | "InvalidTemplateParam"
79        | "NullArgument"
80        | "UndefinedMethod"
81        | "UndefinedProperty" => 6,
82        "AbstractInstantiation"
83        | "InvalidOverride"
84        | "MethodSignatureMismatch"
85        | "OverriddenMethodAccess"
86        | "UnhandledMatchCondition" => 7,
87        _ => return None,
88    })
89}