This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Inform-Software/default-profile-from-text
Replace deprecated XML profile with a simple text file (fixes #65)
- Loading branch information
Showing
9 changed files
with
193 additions
and
455 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
60 changes: 60 additions & 0 deletions
60
sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/GroovySonarWayProfile.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,60 @@ | ||
/* | ||
* Sonar Groovy Plugin | ||
* Copyright (C) 2010-2021 SonarQube Community | ||
* | ||
* 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 org.sonar.plugins.groovy; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.nio.charset.StandardCharsets; | ||
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition; | ||
import org.sonar.plugins.groovy.codenarc.CodeNarcRulesDefinition; | ||
import org.sonar.plugins.groovy.foundation.Groovy; | ||
import org.sonarsource.api.sonarlint.SonarLintSide; | ||
|
||
@SonarLintSide | ||
public class GroovySonarWayProfile implements BuiltInQualityProfilesDefinition { | ||
|
||
@Override | ||
public void define(Context context) { | ||
NewBuiltInQualityProfile sonarWay = | ||
context.createBuiltInQualityProfile("Sonar way", Groovy.KEY); | ||
|
||
addRulesFromText(CodeNarcRulesDefinition.REPOSITORY_KEY, sonarWay); | ||
sonarWay.done(); | ||
} | ||
|
||
private static void addRulesFromText(String repo, NewBuiltInQualityProfile profile) { | ||
try (BufferedReader reader = | ||
new BufferedReader( | ||
new InputStreamReader( | ||
GroovySonarWayProfile.class.getResourceAsStream("profile-default.txt"), | ||
StandardCharsets.UTF_8))) { | ||
reader | ||
.lines() | ||
.forEach( | ||
(String rule) -> { | ||
if (!rule.isEmpty()) { | ||
profile.activateRule(repo, rule); | ||
} | ||
}); | ||
} catch (IOException e) { | ||
throw new IllegalStateException("Failed to read: profile-default.txt", e); | ||
} | ||
} | ||
} |
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
38 changes: 0 additions & 38 deletions
38
sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/codenarc/SonarWayProfile.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
sonar-groovy-plugin/src/main/resources/org/sonar/plugins/groovy/profile-default.txt
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,58 @@ | ||
org.codenarc.rule.basic.AssignmentInConditionalRule | ||
org.codenarc.rule.exceptions.CatchErrorRule | ||
org.codenarc.rule.exceptions.CatchExceptionRule | ||
org.codenarc.rule.exceptions.CatchNullPointerExceptionRule | ||
org.codenarc.rule.exceptions.CatchRuntimeExceptionRule | ||
org.codenarc.rule.design.CloneableWithoutCloneRule | ||
org.codenarc.rule.braces.ElseBlockBracesRule | ||
org.codenarc.rule.grails.GrailsPublicControllerMethodRule.fixed | ||
org.codenarc.rule.grails.GrailsServletContextReferenceRule | ||
org.codenarc.rule.grails.GrailsStatelessServiceRule | ||
org.codenarc.rule.size.NestedBlockDepthRule | ||
org.codenarc.rule.concurrency.NestedSynchronizationRule | ||
org.codenarc.rule.logging.PrintStackTraceRule | ||
org.codenarc.rule.logging.PrintlnRule | ||
org.codenarc.rule.basic.ReturnFromFinallyBlockRule | ||
org.codenarc.rule.concurrency.SynchronizedMethodRule | ||
org.codenarc.rule.logging.SystemErrPrintRule | ||
org.codenarc.rule.logging.SystemOutPrintRule | ||
org.codenarc.rule.concurrency.SystemRunFinalizersOnExitRule | ||
org.codenarc.rule.concurrency.ThreadYieldRule | ||
org.codenarc.rule.exceptions.ThrowErrorRule | ||
org.codenarc.rule.exceptions.ThrowExceptionRule | ||
org.codenarc.rule.basic.ThrowExceptionFromFinallyBlockRule | ||
org.codenarc.rule.exceptions.ThrowNullPointerExceptionRule | ||
org.codenarc.rule.exceptions.ThrowRuntimeExceptionRule | ||
org.codenarc.rule.exceptions.ThrowThrowableRule | ||
org.codenarc.rule.imports.UnnecessaryGroovyImportRule | ||
org.codenarc.rule.imports.UnusedImportRule | ||
org.codenarc.rule.unused.UnusedPrivateFieldRule | ||
org.codenarc.rule.unused.UnusedPrivateMethodRule | ||
org.codenarc.rule.unused.UnusedVariableRule.fixed | ||
org.codenarc.rule.concurrency.VolatileLongOrDoubleFieldRule | ||
org.codenarc.rule.basic.DuplicateCaseStatementRule | ||
org.codenarc.rule.basic.EmptyCatchBlockRule | ||
org.codenarc.rule.basic.EmptyElseBlockRule | ||
org.codenarc.rule.basic.EmptyFinallyBlockRule | ||
org.codenarc.rule.basic.EmptyForStatementRule | ||
org.codenarc.rule.basic.EmptyIfStatementRule | ||
org.codenarc.rule.basic.EmptyInstanceInitializerRule | ||
org.codenarc.rule.basic.EmptyMethodRule | ||
org.codenarc.rule.basic.EmptyStaticInitializerRule | ||
org.codenarc.rule.basic.EmptySwitchStatementRule | ||
org.codenarc.rule.basic.EmptySynchronizedStatementRule | ||
org.codenarc.rule.basic.EmptyTryBlockRule | ||
org.codenarc.rule.basic.EmptyWhileStatementRule | ||
org.codenarc.rule.basic.EqualsAndHashCodeRule | ||
org.codenarc.rule.basic.EqualsOverloadedRule | ||
org.codenarc.rule.basic.EmptyClassRule | ||
org.codenarc.rule.imports.DuplicateImportRule | ||
org.codenarc.rule.imports.ImportFromSamePackageRule | ||
org.codenarc.rule.imports.ImportFromSunPackagesRule | ||
org.codenarc.rule.naming.ClassNameSameAsFilenameRule | ||
org.codenarc.rule.unused.UnusedPrivateMethodParameterRule | ||
org.codenarc.rule.unused.UnusedMethodParameterRule | ||
org.codenarc.rule.convention.ConfusingTernaryRule | ||
org.codenarc.rule.convention.InvertedIfElseRule | ||
org.codenarc.rule.convention.VectorIsObsoleteRule | ||
org.codenarc.rule.convention.HashtableIsObsoleteRule |
Oops, something went wrong.