Class CheckstyleFormatImporter

  • Direct Known Subclasses:
    CheckstyleFormatImporterWithRuleLoader

    public class CheckstyleFormatImporter
    extends java.lang.Object
    Import external linter reports having a "Checkstyle" xml format into SonarQube
    • Constructor Summary

      Constructors 
      Constructor Description
      CheckstyleFormatImporter​(org.sonar.api.batch.sensor.SensorContext context, java.lang.String linterKey)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.sonar.api.rule.RuleKey createRuleKey​(java.lang.String source)  
      protected java.lang.Long effort​(java.lang.String ruleKey)
      Return an Effort value based on the ruleKey.
      void importFile​(java.io.File reportPath)
      "importFile" parses the given report file and imports the content into SonarQube
      protected org.sonar.api.rules.RuleType ruleType​(java.lang.String ruleKey, java.lang.String severity, java.lang.String source)
      Return a RuleType equivalent based on the different parameters.
      protected org.sonar.api.batch.rule.Severity severity​(java.lang.String ruleKey, java.lang.String severity)
      Return a Severity equivalent based on the different parameters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CheckstyleFormatImporter

        public CheckstyleFormatImporter​(org.sonar.api.batch.sensor.SensorContext context,
                                        java.lang.String linterKey)
        Parameters:
        context - , the context where issues will be sent
        linterKey - , used to specify the rule repository
    • Method Detail

      • importFile

        public void importFile​(java.io.File reportPath)
        "importFile" parses the given report file and imports the content into SonarQube
        Parameters:
        reportPath - , path of the xml file
      • createRuleKey

        @Nullable
        protected org.sonar.api.rule.RuleKey createRuleKey​(java.lang.String source)
      • ruleType

        protected org.sonar.api.rules.RuleType ruleType​(java.lang.String ruleKey,
                                                        @Nullable
                                                        java.lang.String severity,
                                                        java.lang.String source)
        Return a RuleType equivalent based on the different parameters.
        Parameters:
        ruleKey - rule key of the current issue.
        severity - "severity" attribute's value of the report. Ex: "info", "error".
        source - "source" attribute's value of the report. Ex: "gosec", "detekt.MagicNumber".
        Returns:
        the RuleType defined by the given parameters.
      • severity

        protected org.sonar.api.batch.rule.Severity severity​(java.lang.String ruleKey,
                                                             @Nullable
                                                             java.lang.String severity)
        Return a Severity equivalent based on the different parameters.
        Parameters:
        ruleKey - rule key of the current issue.
        severity - "severity" attribute's value of the report. Ex: "info", "error".
        Returns:
        the Severity defined by the given parameters.
      • effort

        protected java.lang.Long effort​(java.lang.String ruleKey)
        Return an Effort value based on the ruleKey.
        Parameters:
        ruleKey - rule key of the current issue.
        Returns:
        the Effort defined by the given ruleKey.