Skip to content

Commit

Permalink
MA0124: Improve configuration to support deny list
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Feb 21, 2024
1 parent 97c11a9 commit fbabed5
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 65 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ If you are already using other analyzers, you can check [which rules are duplica
|[MA0121](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0121.md)|Design|Do not overwrite parameter value|ℹ️|||
|[MA0122](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0122.md)|Design|Parameters with \[SupplyParameterFromQuery\] attributes are only valid in routable components (@page)|ℹ️|✔️||
|[MA0123](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0123.md)|Design|Sequence number must be a constant|⚠️|✔️||
|[MA0124](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0124.md)|Design|Log Parameter type is not valid|⚠️|✔️||
|[MA0124](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0124.md)|Design|Log parameter type is not valid|⚠️|✔️||
|[MA0125](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0125.md)|Design|The list of log parameter types contains an invalid type|⚠️|✔️||
|[MA0126](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0126.md)|Design|The list of log parameter types contains a duplicate|⚠️|✔️||
|[MA0127](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0127.md)|Usage|Use String.Equals instead of is pattern|⚠️|||
Expand All @@ -154,7 +154,7 @@ If you are already using other analyzers, you can check [which rules are duplica
|[MA0136](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0136.md)|Usage|Raw String contains an implicit end of line character|👻|✔️||
|[MA0137](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0137.md)|Design|Use 'Async' suffix when a method returns an awaitable type|⚠️|||
|[MA0138](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0138.md)|Design|Do not use 'Async' suffix when a method does not return an awaitable type|⚠️|||
|[MA0139](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0139.md)|Design|Log Parameter type is not valid|⚠️|✔️||
|[MA0139](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0139.md)|Design|Log parameter type is not valid|⚠️|✔️||
|[MA0140](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0140.md)|Design|Both if and else branch have identical code|⚠️|✔️||
|[MA0141](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0141.md)|Usage|Use pattern matching instead of inequality operators for null check|ℹ️||✔️|
|[MA0142](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0142.md)|Usage|Use pattern matching instead of equality operators for null check|ℹ️||✔️|
Expand Down
12 changes: 6 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
|[MA0121](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0121.md)|Design|Do not overwrite parameter value|<span title='Info'>ℹ️</span>|||
|[MA0122](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0122.md)|Design|Parameters with \[SupplyParameterFromQuery\] attributes are only valid in routable components (@page)|<span title='Info'>ℹ️</span>|✔️||
|[MA0123](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0123.md)|Design|Sequence number must be a constant|<span title='Warning'>⚠️</span>|✔️||
|[MA0124](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0124.md)|Design|Log Parameter type is not valid|<span title='Warning'>⚠️</span>|✔️||
|[MA0124](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0124.md)|Design|Log parameter type is not valid|<span title='Warning'>⚠️</span>|✔️||
|[MA0125](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0125.md)|Design|The list of log parameter types contains an invalid type|<span title='Warning'>⚠️</span>|✔️||
|[MA0126](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0126.md)|Design|The list of log parameter types contains a duplicate|<span title='Warning'>⚠️</span>|✔️||
|[MA0127](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0127.md)|Usage|Use String.Equals instead of is pattern|<span title='Warning'>⚠️</span>|||
Expand All @@ -138,7 +138,7 @@
|[MA0136](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0136.md)|Usage|Raw String contains an implicit end of line character|<span title='Hidden'>👻</span>|✔️||
|[MA0137](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0137.md)|Design|Use 'Async' suffix when a method returns an awaitable type|<span title='Warning'>⚠️</span>|||
|[MA0138](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0138.md)|Design|Do not use 'Async' suffix when a method does not return an awaitable type|<span title='Warning'>⚠️</span>|||
|[MA0139](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0139.md)|Design|Log Parameter type is not valid|<span title='Warning'>⚠️</span>|✔️||
|[MA0139](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0139.md)|Design|Log parameter type is not valid|<span title='Warning'>⚠️</span>|✔️||
|[MA0140](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0140.md)|Design|Both if and else branch have identical code|<span title='Warning'>⚠️</span>|✔️||
|[MA0141](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0141.md)|Usage|Use pattern matching instead of inequality operators for null check|<span title='Info'>ℹ️</span>||✔️|
|[MA0142](https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0142.md)|Usage|Use pattern matching instead of equality operators for null check|<span title='Info'>ℹ️</span>||✔️|
Expand Down Expand Up @@ -529,7 +529,7 @@ dotnet_diagnostic.MA0122.severity = suggestion
# MA0123: Sequence number must be a constant
dotnet_diagnostic.MA0123.severity = warning
# MA0124: Log Parameter type is not valid
# MA0124: Log parameter type is not valid
dotnet_diagnostic.MA0124.severity = warning
# MA0125: The list of log parameter types contains an invalid type
Expand Down Expand Up @@ -574,7 +574,7 @@ dotnet_diagnostic.MA0137.severity = none
# MA0138: Do not use 'Async' suffix when a method does not return an awaitable type
dotnet_diagnostic.MA0138.severity = none
# MA0139: Log Parameter type is not valid
# MA0139: Log parameter type is not valid
dotnet_diagnostic.MA0139.severity = warning
# MA0140: Both if and else branch have identical code
Expand Down Expand Up @@ -989,7 +989,7 @@ dotnet_diagnostic.MA0122.severity = none
# MA0123: Sequence number must be a constant
dotnet_diagnostic.MA0123.severity = none
# MA0124: Log Parameter type is not valid
# MA0124: Log parameter type is not valid
dotnet_diagnostic.MA0124.severity = none
# MA0125: The list of log parameter types contains an invalid type
Expand Down Expand Up @@ -1034,7 +1034,7 @@ dotnet_diagnostic.MA0137.severity = none
# MA0138: Do not use 'Async' suffix when a method does not return an awaitable type
dotnet_diagnostic.MA0138.severity = none
# MA0139: Log Parameter type is not valid
# MA0139: Log parameter type is not valid
dotnet_diagnostic.MA0139.severity = none
# MA0140: Both if and else branch have identical code
Expand Down
5 changes: 4 additions & 1 deletion docs/Rules/MA0124.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MA0124 - Log Parameter type is not valid
# MA0124 - Log parameter type is not valid

This rule ensures the parameters for Microsoft.Extensions.Logging's logger are of the expected types. You can configure the expected types using a configuration file.

Expand All @@ -14,6 +14,9 @@ Name;System.String
Count;System.Int32;System.Int64
Length;System.Int32;System.Nullable{System.Int32}
AccountId;System.Nullable{System.Guid}
# Deny parameter
InvalidParameter;
````

Then, you need to add the file to the `AdditionalFiles` collection in the `csproj` file:
Expand Down
5 changes: 4 additions & 1 deletion docs/Rules/MA0139.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MA0139 - Log Parameter type is not valid
# MA0139 - Log parameter type is not valid

This rule ensures the parameters for Serilog's logger are of the expected types. You can configure the expected types using a configuration file.

Expand All @@ -14,6 +14,9 @@ Name;System.String
Count;System.Int32;System.Int64
Length;System.Int32;System.Nullable{System.Int32}
AccountId;System.Nullable{System.Guid}
# Deny parameter
InvalidParameter;
````

Then, you need to add the file to the `AdditionalFiles` collection in the `csproj` file:
Expand Down

0 comments on commit fbabed5

Please sign in to comment.