Skip to content

Commit

Permalink
replace deprecated RulesDefinitionXmlLoader
Browse files Browse the repository at this point in the history
[API Changes / Release 9.0](https://docs.sonarqube.org/latest/extension-guide/developing-a-plugin/plugin-basics/#api-changes)
* Deprecated: `org.sonar.api.server.rule.RulesDefinitionXmlLoader` is deprecated. Use the sonar-check-api to annotate rule classes instead of loading the metadata from XML files.
* use own `RulesDefinitionXmlLoader` to continue with XML format
  • Loading branch information
guwirth committed Dec 29, 2022
1 parent aac2f79 commit 70fa283
Show file tree
Hide file tree
Showing 34 changed files with 880 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.clangsa;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.clangtidy;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.compiler.gcc;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.compiler.vc;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.cppcheck;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.drmemory;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.infer;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import java.nio.charset.StandardCharsets;
import org.sonar.api.config.Configuration;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* Loads the external rules configuration file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.pclint;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.sonar.cxx.sensors.rats;

import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.cxx.sensors.utils.RulesDefinitionXml;
import org.sonar.cxx.sensors.utils.RulesDefinitionXmlLoader;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.commons.io.FileUtils;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;

Expand Down Expand Up @@ -77,7 +76,7 @@ public void define(Context context) {
xmlLoader.load(repository, xmlStream, encoding);

for (var userExtensionXml : getExtensions(repositoryKey, "xml")) {
try ( var input = java.nio.file.Files.newInputStream(userExtensionXml.toPath())) {
try (var input = java.nio.file.Files.newInputStream(userExtensionXml.toPath())) {
xmlRuleLoader.load(repository, input, encoding);
} catch (IOException | IllegalStateException e) {
LOG.error("Cannot load Rules Definions '{}'", e.getMessage());
Expand Down
Loading

0 comments on commit 70fa283

Please sign in to comment.