diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f1c1e90f..75f628259 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#19](https://github.com/green-code-initiative/ecoCode-common/issues/19) process changed for development environment installation : easier to initialize locally environment (check [`INSTALL.md`](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/INSTALL.md#howto-install-sonarqube-dev-environment) file)
- [#187](https://github.com/green-code-initiative/ecoCode/issues/187) upgrade librairies to SonarQube 10.0.0
- [#196](https://github.com/green-code-initiative/ecoCode/issues/196) updating PHP files to make them following the coding standards (PSR-12)
+- [#201](https://github.com/green-code-initiative/ecoCode/pull/201) Clean-up plugins and dependencies
- technical : upgrade of maven plugins versions
### Deleted
@@ -159,3 +160,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.1.1]: https://github.com/green-code-initiative/ecoCode/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/green-code-initiative/ecoCode/releases/tag/v0.1.0
+
diff --git a/java-plugin/pom.xml b/java-plugin/pom.xml
index 773c3a0bd..c750fd98e 100644
--- a/java-plugin/pom.xml
+++ b/java-plugin/pom.xml
@@ -28,22 +28,11 @@
sonar-plugin-api
-
- org.sonarsource.sonarqube
- sonar-plugin-api-impl
-
-
org.sonarsource.analyzer-commons
sonar-analyzer-commons
-
- org.apache.commons
- commons-lang3
- 3.11
-
-
com.google.re2j
@@ -69,6 +58,12 @@
test
+
+ org.mockito
+ mockito-junit-jupiter
+ test
+
+
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaCheckRegistrar.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaCheckRegistrar.java
index 1d92303b1..5705e6ec5 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaCheckRegistrar.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaCheckRegistrar.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java;
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaPlugin.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaPlugin.java
index 1e40808d8..3ccc016e8 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaPlugin.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaPlugin.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,17 +11,13 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java;
import org.sonar.api.Plugin;
-/**
- * Entry point of your plugin containing your custom rules
- */
public class JavaPlugin implements Plugin {
@Override
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaRulesDefinition.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaRulesDefinition.java
index 37a82c438..56324e89e 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaRulesDefinition.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/JavaRulesDefinition.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,25 +11,20 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java;
+import org.sonar.api.SonarRuntime;
+import org.sonar.api.server.rule.RulesDefinition;
+import org.sonarsource.analyzer.commons.RuleMetadataLoader;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
-import org.sonar.api.SonarEdition;
-import org.sonar.api.SonarQubeSide;
-import org.sonar.api.SonarRuntime;
-import org.sonar.api.internal.SonarRuntimeImpl;
-import org.sonar.api.server.rule.RulesDefinition;
-import org.sonar.api.utils.Version;
-import org.sonarsource.analyzer.commons.RuleMetadataLoader;
-
/**
* Declare rule metadata in server repository of rules.
* That allows to list the rules in the page "Rules".
@@ -48,12 +41,16 @@ public class JavaRulesDefinition implements RulesDefinition {
public static final String LANGUAGE = "java";
public static final String REPOSITORY_KEY = "ecocode-java";
+ private final SonarRuntime sonarRuntime;
+
+ public JavaRulesDefinition(SonarRuntime sonarRuntime) {
+ this.sonarRuntime = sonarRuntime;
+ }
+
@Override
public void define(Context context) {
NewRepository repository = context.createRepository(REPOSITORY_KEY, LANGUAGE).setName(NAME);
- SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(10, 0), SonarQubeSide.SCANNER, SonarEdition.DEVELOPER);
-
RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH, sonarRuntime);
ruleMetadataLoader.addRulesByAnnotatedClass(repository, new ArrayList<>(RulesList.getChecks()));
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/RulesList.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/RulesList.java
index 8f2a47c47..850e141c7 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/RulesList.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/RulesList.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java;
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java
index 0e334905d..d8a7e69da 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java
@@ -1,39 +1,16 @@
package fr.greencodeinitiative.java.checks;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.CheckForNull;
-
-import org.apache.commons.lang3.StringUtils;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.plugins.java.api.JavaFileScanner;
import org.sonar.plugins.java.api.JavaFileScannerContext;
-import org.sonar.plugins.java.api.tree.AssignmentExpressionTree;
-import org.sonar.plugins.java.api.tree.BaseTreeVisitor;
-import org.sonar.plugins.java.api.tree.BinaryExpressionTree;
-import org.sonar.plugins.java.api.tree.BlockTree;
-import org.sonar.plugins.java.api.tree.ExpressionTree;
-import org.sonar.plugins.java.api.tree.ForEachStatement;
-import org.sonar.plugins.java.api.tree.IdentifierTree;
-import org.sonar.plugins.java.api.tree.IfStatementTree;
-import org.sonar.plugins.java.api.tree.MemberSelectExpressionTree;
-import org.sonar.plugins.java.api.tree.MethodInvocationTree;
-import org.sonar.plugins.java.api.tree.NewClassTree;
-import org.sonar.plugins.java.api.tree.ReturnStatementTree;
-import org.sonar.plugins.java.api.tree.StatementTree;
-import org.sonar.plugins.java.api.tree.ThrowStatementTree;
-import org.sonar.plugins.java.api.tree.Tree;
+import org.sonar.plugins.java.api.tree.*;
import org.sonar.plugins.java.api.tree.Tree.Kind;
-import org.sonar.plugins.java.api.tree.TypeCastTree;
-import org.sonar.plugins.java.api.tree.UnaryExpressionTree;
-import org.sonar.plugins.java.api.tree.VariableTree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
+import javax.annotation.CheckForNull;
+import java.util.*;
+
@Rule(key = "EC63", name = "Developpement", description = "Do not unnecessarily assign values to variables", priority = Priority.MINOR,
tags = {"eco-design", "ecocode", "memory"})
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S63")
@@ -191,7 +168,7 @@ private void checkImmediatelyReturnedVariable(BlockTree tree) {
String lastStatementIdentifier = getReturnOrThrowIdentifier(lastStatement);
if (lastStatementIdentifier != null) {
String identifier = variableTree.simpleName().name();
- if (StringUtils.equals(lastStatementIdentifier, identifier)) {
+ if (lastStatementIdentifier.equals(identifier)) {
context.reportIssue(this, variableTree.initializer(), errorMessage);
}
}
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/package-info.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/package-info.java
deleted file mode 100644
index 03dc1c94a..000000000
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package fr.greencodeinitiative.java.checks;
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/package-info.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/package-info.java
deleted file mode 100644
index 5f3b0c8b2..000000000
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package fr.greencodeinitiative.java;
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/PrinterVisitor.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/PrinterVisitor.java
index 2cb531718..7e796b1a3 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/PrinterVisitor.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/PrinterVisitor.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java.utils;
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/StringUtils.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/StringUtils.java
index 78f6e4df6..bc6ec9d89 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/StringUtils.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/StringUtils.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java.utils;
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/package-info.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/package-info.java
deleted file mode 100644
index f88cc6249..000000000
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/utils/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package fr.greencodeinitiative.java.utils;
diff --git a/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaCheckRegistrarTest.java b/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaCheckRegistrarTest.java
index 3225b1a56..29cc52ae2 100644
--- a/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaCheckRegistrarTest.java
+++ b/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaCheckRegistrarTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,16 +11,16 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java;
-import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.sonar.plugins.java.api.CheckRegistrar;
+import static org.assertj.core.api.Assertions.assertThat;
+
class JavaCheckRegistrarTest {
@Test
@@ -35,4 +33,5 @@ void checkNumberRules() {
assertThat(context.checkClasses()).hasSize(19);
assertThat(context.testCheckClasses()).isEmpty();
}
+
}
diff --git a/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaPluginTest.java b/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaPluginTest.java
index 649268421..c925ece4e 100644
--- a/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaPluginTest.java
+++ b/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaPluginTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,53 +11,28 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java;
-import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.sonar.api.Plugin;
-import org.sonar.api.SonarEdition;
-import org.sonar.api.SonarProduct;
-import org.sonar.api.SonarQubeSide;
import org.sonar.api.SonarRuntime;
-import org.sonar.api.utils.Version;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
class JavaPluginTest {
@Test
void testName() {
- Plugin.Context context = new Plugin.Context(new MockedSonarRuntime());
+ SonarRuntime sonarRuntime = mock(SonarRuntime.class);
+ Plugin.Context context = new Plugin.Context(sonarRuntime);
new JavaPlugin().define(context);
assertThat(context.getExtensions()).hasSize(2);
}
- private static class MockedSonarRuntime implements SonarRuntime {
-
- @Override
- public Version getApiVersion() {
- return Version.create(10, 0);
- }
-
- @Override
- public SonarProduct getProduct() {
- return SonarProduct.SONARQUBE;
- }
-
- @Override
- public SonarQubeSide getSonarQubeSide() {
- return SonarQubeSide.SCANNER;
- }
-
- @Override
- public SonarEdition getEdition() {
- return SonarEdition.COMMUNITY;
- }
- }
-
}
diff --git a/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaRulesDefinitionTest.java b/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaRulesDefinitionTest.java
index 45bd537e2..20aabc21c 100644
--- a/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaRulesDefinitionTest.java
+++ b/java-plugin/src/test/java/fr/greencodeinitiative/java/JavaRulesDefinitionTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java;
@@ -23,14 +20,18 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.sonar.api.SonarRuntime;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.debt.DebtRemediationFunction.Type;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinition.Param;
import org.sonar.api.server.rule.RulesDefinition.Repository;
import org.sonar.api.server.rule.RulesDefinition.Rule;
+import org.sonar.api.utils.Version;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
class JavaRulesDefinitionTest {
@@ -38,8 +39,10 @@ class JavaRulesDefinitionTest {
@BeforeEach
void init() {
- final JavaRulesDefinition rulesDefinition = new JavaRulesDefinition();
- final RulesDefinition.Context context = new RulesDefinition.Context();
+ SonarRuntime sonarRuntime = mock(SonarRuntime.class);
+ doReturn(Version.create(0, 0)).when(sonarRuntime).getApiVersion();
+ JavaRulesDefinition rulesDefinition = new JavaRulesDefinition(sonarRuntime);
+ RulesDefinition.Context context = new RulesDefinition.Context();
rulesDefinition.define(context);
repository = context.repository(JavaRulesDefinition.REPOSITORY_KEY);
}
diff --git a/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/FilesUtils.java b/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/FilesUtils.java
index 37be25da4..121607764 100644
--- a/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/FilesUtils.java
+++ b/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/FilesUtils.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java.utils;
diff --git a/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/StringUtilsTest.java b/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/StringUtilsTest.java
index c0eee7c3c..25b5b6791 100644
--- a/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/StringUtilsTest.java
+++ b/java-plugin/src/test/java/fr/greencodeinitiative/java/utils/StringUtilsTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Java
- * Copyright (C) 2012-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.java.utils;
diff --git a/javascript-plugin/pom.xml b/javascript-plugin/pom.xml
index 547a2a2df..ab0c3a81c 100644
--- a/javascript-plugin/pom.xml
+++ b/javascript-plugin/pom.xml
@@ -28,11 +28,6 @@
sonar-plugin-api
-
- org.sonarsource.sonarqube
- sonar-plugin-api-impl
-
-
org.sonarsource.analyzer-commons
sonar-analyzer-commons
@@ -50,6 +45,12 @@
test
+
+ org.mockito
+ mockito-junit-jupiter
+ test
+
+
diff --git a/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptPlugin.java b/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptPlugin.java
index 6959ea2e1..66dba696c 100644
--- a/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptPlugin.java
+++ b/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptPlugin.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2023 Green Code Initiative
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser 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 .
+ */
package fr.greencodeinitiative.javascript;
import org.sonar.api.Plugin;
diff --git a/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptRulesDefinition.java b/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptRulesDefinition.java
index e5fbae09d..f13409ce4 100644
--- a/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptRulesDefinition.java
+++ b/javascript-plugin/src/main/java/fr/greencodeinitiative/javascript/JavaScriptRulesDefinition.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2023 Green Code Initiative
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser 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 .
+ */
package fr.greencodeinitiative.javascript;
import org.sonar.api.server.rule.RulesDefinition;
diff --git a/javascript-plugin/src/test/java/fr/greencodeinitiative/javascript/JavaScriptPluginTest.java b/javascript-plugin/src/test/java/fr/greencodeinitiative/javascript/JavaScriptPluginTest.java
index 3f8ed8f3f..84534777c 100644
--- a/javascript-plugin/src/test/java/fr/greencodeinitiative/javascript/JavaScriptPluginTest.java
+++ b/javascript-plugin/src/test/java/fr/greencodeinitiative/javascript/JavaScriptPluginTest.java
@@ -1,41 +1,20 @@
package fr.greencodeinitiative.javascript;
import org.junit.jupiter.api.Test;
-import org.sonar.api.*;
-import org.sonar.api.utils.Version;
+import org.sonar.api.Plugin;
+import org.sonar.api.SonarRuntime;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
class JavaScriptPluginTest {
@Test
void extensions() {
- Plugin.Context context = new Plugin.Context(new MockedSonarRuntime());
+ SonarRuntime sonarRuntime = mock(SonarRuntime.class);
+ Plugin.Context context = new Plugin.Context(sonarRuntime);
new JavaScriptPlugin().define(context);
assertThat(context.getExtensions()).hasSize(1);
}
- private static class MockedSonarRuntime implements SonarRuntime {
-
- @Override
- public Version getApiVersion() {
- return Version.create(10, 0);
- }
-
- @Override
- public SonarProduct getProduct() {
- return SonarProduct.SONARQUBE;
- }
-
- @Override
- public SonarQubeSide getSonarQubeSide() {
- return SonarQubeSide.SCANNER;
- }
-
- @Override
- public SonarEdition getEdition() {
- return SonarEdition.COMMUNITY;
- }
- }
-
}
diff --git a/php-plugin/pom.xml b/php-plugin/pom.xml
index 3ee2639c8..ad70f265d 100644
--- a/php-plugin/pom.xml
+++ b/php-plugin/pom.xml
@@ -28,11 +28,6 @@
sonar-plugin-api
-
- org.sonarsource.sonarqube
- sonar-plugin-api-impl
-
-
@@ -45,6 +40,13 @@
assertj-core
test
+
+
+ org.mockito
+ mockito-junit-jupiter
+ test
+
+
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/PHPPlugin.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/PHPPlugin.java
index c9bd1ce55..1a7afec6e 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/PHPPlugin.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/PHPPlugin.java
@@ -1,7 +1,5 @@
/*
- * SonarQube PHP Custom Rules Example
- * Copyright (C) 2016-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,21 +11,18 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.php;
import org.sonar.api.Plugin;
-/**
- * Extension point to define a Sonar Plugin.
- */
public class PHPPlugin implements Plugin {
@Override
public void define(Context context) {
context.addExtension(PhpRuleRepository.class);
}
+
}
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java
index 89d05f894..d0fd50e53 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.php;
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java
index 1c6168ca3..79bd2cb4a 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java
@@ -1,22 +1,3 @@
-/*
- * SonarQube PHP Custom Rules Example
- * Copyright (C) 2016-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package fr.greencodeinitiative.php.checks;
import java.util.Collections;
diff --git a/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpPluginTest.java b/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpPluginTest.java
index b64679cbb..33736bc4c 100644
--- a/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpPluginTest.java
+++ b/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpPluginTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,28 +11,26 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.php;
-import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.sonar.api.Plugin;
-import org.sonar.api.SonarEdition;
-import org.sonar.api.SonarQubeSide;
import org.sonar.api.SonarRuntime;
-import org.sonar.api.internal.PluginContextImpl;
-import org.sonar.api.internal.SonarRuntimeImpl;
-import org.sonar.api.utils.Version;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
public class PhpPluginTest {
+
@Test
public void test() {
- SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(10, 0), SonarQubeSide.SCANNER, SonarEdition.DEVELOPER);
- Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(sonarRuntime).build();
+ SonarRuntime sonarRuntime = mock(SonarRuntime.class);
+ Plugin.Context context = new Plugin.Context(sonarRuntime);
new PHPPlugin().define(context);
assertThat(context.getExtensions()).hasSize(1);
}
+
}
diff --git a/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpRuleRepositoryTest.java b/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpRuleRepositoryTest.java
index 3a124f382..70ef4cae8 100644
--- a/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpRuleRepositoryTest.java
+++ b/php-plugin/src/test/java/fr/greencodeinitiative/php/PhpRuleRepositoryTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.php;
diff --git a/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheckTest.java b/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheckTest.java
index 4b8bda378..ca0256117 100644
--- a/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheckTest.java
+++ b/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheckTest.java
@@ -1,33 +1,11 @@
-/*
- * SonarQube PHP Custom Rules Example
- * Copyright (C) 2016-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package fr.greencodeinitiative.php.checks;
-import java.io.File;
-
import org.junit.Test;
import org.sonar.plugins.php.api.tests.PHPCheckTest;
import org.sonar.plugins.php.api.tests.PhpTestFile;
-/**
- * Test class to test the check implementation.
- */
+import java.io.File;
+
public class AvoidUsingGlobalVariablesCheckTest {
@Test
diff --git a/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/IncrementCheckTest.java b/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/IncrementCheckTest.java
index 08e364ab2..7da3216e5 100644
--- a/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/IncrementCheckTest.java
+++ b/php-plugin/src/test/java/fr/greencodeinitiative/php/checks/IncrementCheckTest.java
@@ -1,22 +1,3 @@
-/*
- * SonarQube PHP Custom Rules Example
- * Copyright (C) 2016-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package fr.greencodeinitiative.php.checks;
import java.io.File;
@@ -25,9 +6,6 @@
import org.sonar.plugins.php.api.tests.PHPCheckTest;
import org.sonar.plugins.php.api.tests.PhpTestFile;
-/**
- * Test class to test the check implementation.
- */
public class IncrementCheckTest {
@Test
diff --git a/pom.xml b/pom.xml
index da289faa3..bead6defc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,6 @@
https://sonarcloud.io
9.4.0.54424
- 10.0.0.68432
7.19.0.31550
4.3.0.11660
3.29.0.9684
@@ -67,6 +66,7 @@
5.9.1
3.23.1
+ 5.3.1
1.7
@@ -89,12 +89,6 @@
${sonar-analyzer-commons.version}
-
- org.sonarsource.sonarqube
- sonar-plugin-api-impl
- ${sonar-plugin-api-impl.version}
-
-
com.google.re2j
@@ -160,6 +154,13 @@
test
+
+ org.mockito
+ mockito-junit-jupiter
+ ${mockito.version}
+ test
+
+
org.sonarsource.python
python-checks-testkit
diff --git a/python-plugin/pom.xml b/python-plugin/pom.xml
index e16bdca63..7fd808178 100644
--- a/python-plugin/pom.xml
+++ b/python-plugin/pom.xml
@@ -27,10 +27,6 @@
org.sonarsource.sonarqube
sonar-plugin-api
-
- org.sonarsource.sonarqube
- sonar-plugin-api-impl
-
@@ -44,6 +40,12 @@
test
+
+ org.mockito
+ mockito-junit-jupiter
+ test
+
+
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonPlugin.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonPlugin.java
index 73678cb08..cb8012554 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonPlugin.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonPlugin.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.python;
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java
index 2fb5938de..2718b28f0 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,12 +11,17 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.python;
+import fr.greencodeinitiative.python.checks.*;
+import org.sonar.api.rules.RuleType;
+import org.sonar.api.server.rule.RulesDefinition;
+import org.sonar.api.server.rule.RulesDefinitionAnnotationLoader;
+import org.sonar.plugins.python.api.PythonCustomRuleRepository;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -29,14 +32,6 @@
import java.util.List;
import java.util.Map;
-
-import fr.greencodeinitiative.python.checks.*;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.rules.RuleType;
-import org.sonar.api.server.rule.RulesDefinition;
-import org.sonar.api.server.rule.RulesDefinitionAnnotationLoader;
-import org.sonar.plugins.python.api.PythonCustomRuleRepository;
-
public class PythonRuleRepository implements RulesDefinition, PythonCustomRuleRepository {
public static final String LANGUAGE = "py";
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/package-info.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/package-info.java
deleted file mode 100644
index 63be179f7..000000000
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package fr.greencodeinitiative.python.checks;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/package-info.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/package-info.java
index 58299e2f7..51a7a570e 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/package-info.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/package-info.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
@ParametersAreNonnullByDefault
package fr.greencodeinitiative.python;
diff --git a/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonPluginTest.java b/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonPluginTest.java
index a5ad52390..477f5d4bb 100644
--- a/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonPluginTest.java
+++ b/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonPluginTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,28 +11,26 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.python;
-import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.sonar.api.Plugin;
-import org.sonar.api.SonarEdition;
-import org.sonar.api.SonarQubeSide;
import org.sonar.api.SonarRuntime;
-import org.sonar.api.internal.PluginContextImpl;
-import org.sonar.api.internal.SonarRuntimeImpl;
-import org.sonar.api.utils.Version;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
public class PythonPluginTest {
+
@Test
public void test() {
- SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(10, 0), SonarQubeSide.SCANNER, SonarEdition.DEVELOPER);
- Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(sonarRuntime).build();
+ SonarRuntime sonarRuntime = mock(SonarRuntime.class);
+ Plugin.Context context = new Plugin.Context(sonarRuntime);
new PythonPlugin().define(context);
assertThat(context.getExtensions()).hasSize(1);
}
+
}
diff --git a/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java b/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java
index c21cc4fc8..828447a4d 100644
--- a/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java
+++ b/python-plugin/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java
@@ -1,7 +1,5 @@
/*
- * SonarQube Python Plugin
- * Copyright (C) 2012-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
+ * Copyright (C) 2023 Green Code Initiative
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,9 +11,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package fr.greencodeinitiative.python;