Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE 21] depreciate irrelevant EC69 + delete deprecated EC66 + check 10.4.1 SonarQube compatibility #22

Merged
merged 8 commits into from
Jul 18, 2024
Merged
Prev Previous commit
Next Next commit
[ISSUE 21] keep EC69 depreciation
dedece35 committed Jul 17, 2024

Verified

This commit was signed with the committer’s verified signature.
sandy081 Sandeep Somavarapu
commit 047796fe97ee66b850fc0dceb72eeb06a03ad2df
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -13,8 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [#22](https://github.com/green-code-initiative/ecoCode-python/issues/22) Depreciation of EC69 rule for python because not relevant (after analysis)

### Deleted

- [#22](https://github.com/green-code-initiative/ecoCode-python/issues/22) Delete deprecated EC66 rule for Python

## [1.4.3] - 2024-05-15

### Added
@@ -27,9 +31,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#17](https://github.com/green-code-initiative/ecoCode-python/issues/17) EC7 - correction setter problem on constructor method
- check Sonarqube 10.4.1 compatibility + update docker files and README.md / NOT OK with 10.5.x (issue created)

- [#4](https://github.com/green-code-initiative/ecoCode-python/issues/4) Deprecate rule EC66 for Python because not applicable (see details inside issue)
- [#21](https://github.com/green-code-initiative/ecoCode-python/issues/21) Deletion of EC69 for python because not relevant (after analysis)

## [1.4.2] - 2024-01-11

### Changed
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* ecoCode - Python language - Provides rules to reduce the environmental footprint of your Python programs
* Copyright © 2023 Green Code Initiative (https://www.ecocode.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.greencodeinitiative.python.checks;

import org.sonar.check.Rule;
import org.sonar.plugins.python.api.PythonSubscriptionCheck;
import org.sonar.plugins.python.api.tree.CallExpression;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

/**
* @deprecated not applicable for Python
* (check discussion inside issue https://github.com/green-code-initiative/ecoCode-python/issues/21)
*/
@Deprecated(forRemoval = true)
@Rule(key = "EC69")
@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S69")
public class NoFunctionCallWhenDeclaringForLoop extends PythonSubscriptionCheck {

public static final String DESCRIPTION = "Do not call a function when declaring a for-type loop";

@Override
public void initialize(Context context) {
context.registerSyntaxNodeConsumer(Tree.Kind.CALL_EXPR, ctx -> {
CallExpression callExpression = (CallExpression) ctx.syntaxNode();
if (callExpression.parent().getKind() == Tree.Kind.FOR_STMT) {
ctx.addIssue(callExpression, NoFunctionCallWhenDeclaringForLoop.DESCRIPTION);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ void testMetadata() {

@Test
void testRegistredRules() {
assertThat(repository.rules()).hasSize(12);
assertThat(repository.rules()).hasSize(10);
}

@Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* ecoCode - Python language - Provides rules to reduce the environmental footprint of your Python programs
* Copyright © 2023 Green Code Initiative (https://www.ecocode.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.greencodeinitiative.python.checks;

import org.junit.Test;
import org.sonar.python.checks.utils.PythonCheckVerifier;

@Deprecated
public class NoFunctionCallWhenDeclaringForLoopTest {
@Test
public void test() {
PythonCheckVerifier.verify("src/test/resources/checks/noFunctionCallWhenDeclaringForLoop.py", new NoFunctionCallWhenDeclaringForLoop());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def my_function():
return 6

for i in my_function(): # Noncompliant {{Do not call a function when declaring a for-type loop}}
print("Test")
my_function()
pass

my_function()