Skip to content

Commit 0794c91

Browse files
committed
sonar issues correction
1 parent 679e4d2 commit 0794c91

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
- refactoring docker system
1515
- [#29](https://github.com/green-code-initiative/ecoCode-python/issues/29) Add test to ensure all Rules are registered
16-
- [#24](https://github.com/green-code-initiative/ecoCode-python/issues/24) Set correct required language because the plugin wasn't loaded anymore => change of retro-compatibility (9.9.0 to 10.7 and not compatible before 9.9.0) AND add support for > 10.5 Sonarqube version (up to 10.7.0)
17-
- update some maven plugin versions and librarie versions to be up-to-date
16+
- [#24](https://github.com/green-code-initiative/ecoCode-python/issues/24) Set correct required language because the
17+
plugin wasn't loaded anymore - retro-compatibility modifications (9.9.0 to 10.7 and not compatible before 9.9.0) AND
18+
add support for > 10.5 Sonarqube version (up to 10.7.0)
19+
- update some maven plugin versions and library versions to be up-to-date
20+
- correction of SonarCloud issues
1821

1922
### Deleted
2023

21-
- delete EC69 rule because of deprecation (see RULES.md file)
24+
- deletion of EC69 rule because of already deprecated (see RULES.md file)
2225

2326
## [1.4.4] - 2024-07-18
2427

@@ -39,7 +42,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3942

4043
### Added
4144

42-
- [#18](https://github.com/green-code-initiative/ecoCode-python/issues/18) Add support for SonarQube 10.4 "DownloadOnlyWhenRequired" feature
45+
- [#18](https://github.com/green-code-initiative/ecoCode-python/issues/18) Add support for SonarQube 10.4 "
46+
DownloadOnlyWhenRequired" feature
4347
- Add Support for SonarQube 10.4.1
4448

4549
### Changed
@@ -66,7 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6670
- [#5](https://github.com/green-code-initiative/ecoCode-python/pull/5) Upgrade licence system and licence headers of
6771
Java files
6872
- [#6](https://github.com/green-code-initiative/ecoCode-python/pull/6) Adding EC35 rule : EC35 rule replaces EC34 with a
69-
specific use case ("file not found" sepcific)
73+
specific use case ("file not found" specific)
7074
- [#7](https://github.com/green-code-initiative/ecoCode-python/issues/7) Add build number to manifest
7175
- [#123](https://github.com/green-code-initiative/ecoCode/issues/123) Improve unit tests for EC7 rule
7276
- Update ecocode-rules-specifications to 1.4.6

src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import java.util.Arrays;
2727
import java.util.List;
2828

29+
2930
public class PythonRuleRepository implements RulesDefinition, PythonCustomRuleRepository {
3031

32+
@SuppressWarnings("rawtypes") // not possible to make a correction because super class is like that
3133
static final List<Class> ANNOTATED_RULE_CLASSES = Arrays.asList(
3234
AvoidGettersAndSetters.class,
3335
AvoidGlobalVariableInFunctionCheck.class,
@@ -65,6 +67,7 @@ public String repositoryKey() {
6567
return REPOSITORY_KEY;
6668
}
6769

70+
@SuppressWarnings("rawtypes") // not possible to make a correction because super class is like that
6871
@Override
6972
public List<Class> checkClasses() {
7073
return ANNOTATED_RULE_CLASSES;

src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
package fr.greencodeinitiative.python.checks;
1919

2020

21-
import java.util.ArrayList;
22-
import java.util.Collection;
23-
import java.util.HashMap;
24-
import java.util.Map;
25-
import java.util.regex.Pattern;
26-
2721
import org.sonar.check.Rule;
2822
import org.sonar.plugins.python.api.PythonSubscriptionCheck;
2923
import org.sonar.plugins.python.api.SubscriptionContext;
@@ -32,14 +26,18 @@
3226
import org.sonar.plugins.python.api.tree.Tree;
3327
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
3428

29+
import java.util.ArrayList;
30+
import java.util.Collection;
31+
import java.util.HashMap;
32+
import java.util.Map;
33+
import java.util.regex.Pattern;
34+
3535
@Rule(key = "EC74")
3636
@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S74")
3737
public class AvoidFullSQLRequest extends PythonSubscriptionCheck {
3838

39-
protected static final String MESSAGERULE = "Don't use the query SELECT * FROM";
39+
protected static final String MESSAGE_RULE = "Don't use the query SELECT * FROM";
4040

41-
// TODO DDC : create support to add in deployment th dependency com.google.re2j:re2j
42-
// and replace "import java.util.regex.Pattern" by "import com.google.re2j.Pattern"
4341
private static final Pattern PATTERN = Pattern.compile("(?i).*select.*\\*.*from.*");
4442
private static final Map<String, Collection<Integer>> linesWithIssuesByFile = new HashMap<>();
4543

@@ -68,7 +66,7 @@ private void repport(StringElement stringElement, SubscriptionContext ctx) {
6866
linesWithIssuesByFile.computeIfAbsent(classname, k -> new ArrayList<>());
6967
linesWithIssuesByFile.get(classname).add(line);
7068
}
71-
ctx.addIssue(stringElement, MESSAGERULE);
69+
ctx.addIssue(stringElement, MESSAGE_RULE);
7270
}
7371

7472
private boolean lineAlreadyHasThisIssue(StringElement stringElement, SubscriptionContext ctx) {

0 commit comments

Comments
 (0)