-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONARPY-2379 Update the custom rules in the sonar-python repository t…
…o match LAYC format
- Loading branch information
1 parent
42caced
commit d0e3bcc
Showing
9 changed files
with
145 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
docs/python-custom-rule-examples/src/main/java/org/sonar/samples/python/RulesList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2012-2024 SonarSource SA - mailto:info AT sonarsource DOT com | ||
* This code is released under [MIT No Attribution](https://opensource.org/licenses/MIT-0) license. | ||
*/ | ||
package org.sonar.samples.python; | ||
|
||
import java.util.List; | ||
import java.util.stream.Stream; | ||
import org.sonar.plugins.python.api.PythonCheck; | ||
import org.sonar.samples.python.checks.CustomPythonSubscriptionCheck; | ||
import org.sonar.samples.python.checks.CustomPythonVisitorCheck; | ||
|
||
public final class RulesList { | ||
|
||
private RulesList() { | ||
} | ||
|
||
public static List<Class<? extends PythonCheck>> getChecks() { | ||
return Stream.concat( | ||
getPythonChecks().stream(), | ||
getPythonTestChecks().stream() | ||
).toList(); | ||
} | ||
|
||
/** | ||
* These rules are going to target MAIN code only | ||
*/ | ||
public static List<Class<? extends PythonCheck>> getPythonChecks() { | ||
return List.of( | ||
CustomPythonSubscriptionCheck.class | ||
); | ||
} | ||
|
||
/** | ||
* These rules are going to target TEST code only | ||
*/ | ||
public static List<Class<? extends PythonCheck>> getPythonTestChecks() { | ||
return List.of( | ||
CustomPythonVisitorCheck.class | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...tom-rule-examples/src/main/resources/org/sonar/l10n/python/rules/python/subscription.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"title": "Python subscription visitor check", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "5min" | ||
}, | ||
"tags": [ | ||
"pitfall" | ||
], | ||
"defaultSeverity": "Minor" | ||
} |
13 changes: 13 additions & 0 deletions
13
...n-custom-rule-examples/src/main/resources/org/sonar/l10n/python/rules/python/visitor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"title": "Python visitor check", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "5min" | ||
}, | ||
"tags": [ | ||
"pitfall" | ||
], | ||
"defaultSeverity": "Minor" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters