Skip to content

Commit

Permalink
Fix S109 FP: Reduce false positives for named arguments, attribute us…
Browse files Browse the repository at this point in the history
…age, "From...()" methods and single digit comparisons for well-known properties (#5247)

Fixes #4737
  • Loading branch information
andrei-epure-sonarsource authored Jan 12, 2022
1 parent b27cbb7 commit e594a9d
Show file tree
Hide file tree
Showing 52 changed files with 582 additions and 6,806 deletions.
26 changes: 0 additions & 26 deletions analyzers/its/expected/Automapper/AutoMapper--net461-S109.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,6 @@
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Execution\TypeMapPlanBuilder.cs",
"region": {
"startLine": 42,
"startColumn": 51,
"endLine": 42,
"endColumn": 52
}
}
},
{
"id": "S109",
"message": "Assign this magic number '3' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Execution\TypeMapPlanBuilder.cs",
"region": {
"startLine": 43,
"startColumn": 53,
"endLine": 43,
"endColumn": 54
}
}
},
{
"id": "S109",
"message": "Assign this magic number '10' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Execution\TypeMapPlanBuilder.cs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,6 @@
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Execution\TypeMapPlanBuilder.cs",
"region": {
"startLine": 42,
"startColumn": 51,
"endLine": 42,
"endColumn": 52
}
}
},
{
"id": "S109",
"message": "Assign this magic number '3' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Execution\TypeMapPlanBuilder.cs",
"region": {
"startLine": 43,
"startColumn": 53,
"endLine": 43,
"endColumn": 54
}
}
},
{
"id": "S109",
"message": "Assign this magic number '10' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Execution\TypeMapPlanBuilder.cs",
Expand Down

This file was deleted.

182 changes: 0 additions & 182 deletions analyzers/its/expected/Nancy/Nancy--net452-S109.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Conventions\DefaultAcceptHeaderCoercionConventions.cs",
"region": {
"startLine": 39,
"startColumn": 162,
"endLine": 39,
"endColumn": 163
}
}
},
{
"id": "S109",
"message": "Assign this magic number '32' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Cryptography\AesEncryptionProvider.cs",
Expand Down Expand Up @@ -80,19 +67,6 @@
},
{
"id": "S109",
"message": "Assign this magic number '8' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Cryptography\PassphraseKeyGenerator.cs",
"region": {
"startLine": 26,
"startColumn": 31,
"endLine": 26,
"endColumn": 32
}
}
},
{
"id": "S109",
"message": "Assign this magic number '32' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Helpers\HttpEncoder.cs",
Expand Down Expand Up @@ -745,19 +719,6 @@
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\HttpLinkRelation.cs",
"region": {
"startLine": 144,
"startColumn": 58,
"endLine": 144,
"endColumn": 59
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\HttpMultipart.cs",
"region": {
"startLine": 74,
Expand Down Expand Up @@ -795,19 +756,6 @@
},
{
"id": "S109",
"message": "Assign this magic number '8192' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\IO\RequestStream.cs",
"region": {
"startLine": 416,
"startColumn": 17,
"endLine": 416,
"endColumn": 21
}
}
},
{
"id": "S109",
"message": "Assign this magic number '8196' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\IO\RequestStream.cs",
Expand All @@ -823,19 +771,6 @@
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Owin\NancyMiddleware.cs",
"region": {
"startLine": 239,
"startColumn": 41,
"endLine": 239,
"endColumn": 42
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Request.cs",
"region": {
"startLine": 186,
Expand All @@ -847,123 +782,6 @@
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Response.cs",
"region": {
"startLine": 35,
"startColumn": 51,
"endLine": 35,
"endColumn": 52
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Responses\Negotiation\MediaRange.cs",
"region": {
"startLine": 38,
"startColumn": 32,
"endLine": 38,
"endColumn": 33
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Responses\Negotiation\MediaRange.cs",
"region": {
"startLine": 48,
"startColumn": 33,
"endLine": 48,
"endColumn": 34
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Routing\Constraints\LengthRouteSegmentConstraint.cs",
"region": {
"startLine": 31,
"startColumn": 38,
"endLine": 31,
"endColumn": 39
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Routing\Constraints\RangeRouteSegmentConstraint.cs",
"region": {
"startLine": 34,
"startColumn": 38,
"endLine": 34,
"endColumn": 39
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Routing\Trie\Nodes\CaptureNodeWithDefaultValue.cs",
"region": {
"startLine": 74,
"startColumn": 36,
"endLine": 74,
"endColumn": 37
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Routing\Trie\TrieNodeFactory.cs",
"region": {
"startLine": 48,
"startColumn": 89,
"endLine": 48,
"endColumn": 90
}
}
},
{
"id": "S109",
"message": "Assign this magic number '3' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Security\Csrf.cs",
"region": {
"startLine": 212,
"startColumn": 40,
"endLine": 212,
"endColumn": 41
}
}
},
{
"id": "S109",
"message": "Assign this magic number '2' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\Session\CookieBasedSessions.cs",
"region": {
"startLine": 188,
"startColumn": 105,
"endLine": 188,
"endColumn": 106
}
}
},
{
"id": "S109",
"message": "Assign this magic number '1000' to a well-named (variable|constant), and use the (variable|constant) instead.",
"location": {
"uri": "sources\Nancy\src\Nancy\StaticConfiguration.cs",
Expand Down
Loading

0 comments on commit e594a9d

Please sign in to comment.