Interface SensorContext

    • Method Detail

      • config

        Configuration config()
        Get settings of the project.
        Since:
        6.5
      • fileSystem

        FileSystem fileSystem()
        Get filesystem of the project.
      • activeRules

        ActiveRules activeRules()
        Get list of active rules.
      • module

        @Deprecated
        InputModule module()
        Deprecated.
        since 7.6 modules are deprecated. Use project() instead.
        Throws:
        java.lang.UnsupportedOperationException - for global ProjectSensors
        Since:
        5.5
      • project

        InputProject project()
        The current project.
        Since:
        7.6
      • getSonarQubeVersion

        Version getSonarQubeVersion()
        Version of API at runtime, not at compilation time. It's a shortcut on runtime().getApiVersion() since 6.0.
        Since:
        5.5
        See Also:
        since version 6.0.
      • runtime

        SonarRuntime runtime()
        Runtime information, mainly:
        • to be able to have different behaviours between SonarQube and SonarLint
        • to enable new features depending on version of API available at runtime
        Since:
        6.0
      • isCancelled

        boolean isCancelled()
        Test if a cancellation of the analysis was requested. Sensors should periodically test this flag and gracefully stop if value is true. For example it could be tested between each processed file.
        Since:
        6.0
      • newMeasure

        <G extends java.io.Serializable> NewMeasure<G> newMeasure()
        Fluent builder to create a new Measure. Don't forget to call NewMeasure.save() once all parameters are provided.
      • newIssue

        NewIssue newIssue()
        Fluent builder to create a new Issue. Don't forget to call NewIssue.save() once all parameters are provided.
      • newSymbolTable

        NewSymbolTable newSymbolTable()
        Builder to define symbol table of a file. Don't forget to call NewSymbolTable.save() once all symbols are provided.
        Since:
        5.6
      • newSignificantCode

        NewSignificantCode newSignificantCode()
        Builder to declare which parts of the code is significant code. Ranges that are not reported as significant code will be ignored and won't be considered when calculating which lines were modified. If the significant code is not reported for a file, it is assumed that the entire file is significant code.
        Since:
        7.2
      • addContextProperty

        void addContextProperty​(java.lang.String key,
                                java.lang.String value)
        Add a property to the scanner context. This context is available in Compute Engine when processing the report.
        The properties starting with "sonar.analysis." are included to the payload of webhooks.
        Throws:
        java.lang.IllegalArgumentException - if key or value parameter is null
        Since:
        6.1
        See Also:
        PostProjectAnalysisTask.ProjectAnalysis.getScannerContext()
      • markForPublishing

        void markForPublishing​(InputFile inputFile)
        Indicate that a file should be published in the report sent to SonarQube. Files are automatically marked if any data is created for it (issues, highlighting, coverage, etc.).
        Since:
        6.3