-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting of SonarQube module key bindings by applying a pattern
- Loading branch information
Showing
13 changed files
with
127 additions
and
19 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
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
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
59 changes: 59 additions & 0 deletions
59
src/main/java/de/gebit/plugins/autoconfig/handlers/sonarqube/SonarQubeModuleHandler.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,59 @@ | ||
package de.gebit.plugins.autoconfig.handlers.sonarqube; | ||
|
||
import com.intellij.openapi.module.Module; | ||
import de.gebit.plugins.autoconfig.UpdateModuleHandler; | ||
import de.gebit.plugins.autoconfig.handlers.AbstractHandler; | ||
import de.gebit.plugins.autoconfig.model.SonarQubeConfiguration; | ||
import org.jetbrains.annotations.NonNls; | ||
import org.sonarlint.intellij.config.Settings; | ||
import org.sonarlint.intellij.config.module.SonarLintModuleSettings; | ||
import org.sonarlint.intellij.config.project.SonarLintProjectSettings; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Configuration handler used to synchronise SonarQube module bindings in projects. | ||
*/ | ||
public class SonarQubeModuleHandler extends AbstractHandler implements UpdateModuleHandler<SonarQubeConfiguration> { | ||
private static final @NonNls String CONFIG_SCHEMA_JSON = "/schema/sonarqubeModule.schema.json"; | ||
|
||
public static final @NonNls String CONFIG_FILE_NAME = "autoconfigSonarQubeModule.yaml"; | ||
|
||
@Override | ||
public String getFileName() { | ||
return CONFIG_FILE_NAME; | ||
} | ||
|
||
@Override | ||
public String getJsonSchema() { | ||
return CONFIG_SCHEMA_JSON; | ||
} | ||
|
||
@Override | ||
public String getUpdaterName() { | ||
return "SonarQube module configuration updater"; | ||
} | ||
|
||
@Override | ||
public Class<SonarQubeConfiguration> getConfigurationClass() { | ||
return SonarQubeConfiguration.class; | ||
} | ||
|
||
@Override | ||
public boolean acceptModule(SonarQubeConfiguration configuration, Module module) { | ||
return matchesAnyName(module, configuration.getModuleFilter()); | ||
} | ||
|
||
@Override | ||
public List<String> updateConfiguration(SonarQubeConfiguration configuration, Module module) { | ||
List<String> updatedConfigs = new ArrayList<>(); | ||
SonarLintProjectSettings projectSettings = Settings.getSettingsFor(module.getProject()); | ||
if (projectSettings.isBindingEnabled() && configuration.getProjectKey() != null) { | ||
SonarLintModuleSettings moduleSettings = Settings.getSettingsFor(module); | ||
applySetting(configuration.getProjectKey(), moduleSettings.getProjectKey(), moduleSettings::setProjectKey, | ||
updatedConfigs, "SonarQube module key"); | ||
} | ||
return updatedConfigs; | ||
} | ||
} |
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
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
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,6 @@ | ||
<idea-plugin> | ||
<depends>de.gebit.plugins.autoconfig</depends> | ||
<extensions defaultExtensionNs="de.gebit.plugins.autoconfig"> | ||
<moduleConfigurationUpdater implementation="de.gebit.plugins.autoconfig.handlers.sonarqube.SonarQubeModuleHandler"/> | ||
</extensions> | ||
</idea-plugin> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$id": "https://www.gebit.de/autoconfig-intellij-plugin/sonarqubeModule.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "SonarQube configuration", | ||
"type": "object", | ||
"required": [ | ||
"moduleFilter" | ||
], | ||
"properties": { | ||
"moduleFilter": { | ||
"type": "array", | ||
"description": "List of modules/module regex patterns. Modules that match any of the names/patterns will be configured by this configuration.", | ||
"items": { | ||
"type": "string", | ||
"description": "Module name/pattern" | ||
} | ||
}, | ||
"projectKey": { | ||
"type": "string", | ||
"description": "The SonarQube project key to use for all matching modules" | ||
} | ||
} | ||
} |