public class ShellCheckSensor extends Object implements org.sonar.api.batch.sensor.Sensor
| Modifier and Type | Class and Description |
|---|---|
class |
ShellCheckSensor.UnexpectedCommandOutputException
Class thrown when the executed command does not return the expected output
|
| Constructor and Description |
|---|
ShellCheckSensor(org.sonar.api.batch.fs.FileSystem fileSystem,
org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
describe(org.sonar.api.batch.sensor.SensorDescriptor descriptor) |
void |
execute(org.sonar.api.batch.sensor.SensorContext context)
Executes
shellcheck and saves the issues detected with this tool |
protected int |
executeCommand(List<String> command,
List<String> stdOut,
List<String> errOut)
Executes a system command and writes the standard and error outputs to the passed
StringBuilder if not null |
protected org.sonar.api.rule.RuleKey |
getRuleKey(org.sonar.api.batch.sensor.SensorContext context,
String ruleId)
Returns the
RuleKey identified as the passed ruleId or null if no corresponding active
rule has been found |
protected String |
getShellCheckPath(org.sonar.api.batch.sensor.SensorContext context)
Returns the plugin configuration parameter (settings) that defines the path to the command
shellcheck |
protected void |
saveIssue(org.sonar.api.batch.sensor.SensorContext context,
org.sonar.api.batch.fs.InputFile inputFile,
int line,
String ruleId,
String message)
Saves the found issues in SonarQube
|
protected void |
saveIssues(org.sonar.api.batch.fs.InputFile inputFile,
String output,
org.sonar.api.batch.sensor.SensorContext context)
Saves in SonarQube all the issues found in the passed JSON output.
|
public ShellCheckSensor(org.sonar.api.batch.fs.FileSystem fileSystem,
org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory)
fileSystem - injected by the Sonar framework, used to get access to the scanned filesfileLinesContextFactory - injected by the Sonar framework, used to set line measurespublic void describe(org.sonar.api.batch.sensor.SensorDescriptor descriptor)
describe in interface org.sonar.api.batch.sensor.Sensorpublic void execute(org.sonar.api.batch.sensor.SensorContext context)
shellcheck and saves the issues detected with this toolexecute in interface org.sonar.api.batch.sensor.Sensorcontext - the execution sensor context (taken from the method execute(SensorContext) of the child class)protected String getShellCheckPath(org.sonar.api.batch.sensor.SensorContext context)
shellcheckcontext - the execution sensor context (taken from the method execute(SensorContext) of the child class)shellcheck or shellcheck if the plugin setting is not setShellCheckSettings.SHELLCHECK_PATH_KEYprotected int executeCommand(List<String> command, List<String> stdOut, List<String> errOut) throws InterruptedException, IOException
StringBuilder if not nullcommand - the command to be executedstdOut - where the standard output is written to line by lineerrOut - where the error output is written toIOException - if an error occurred executing the command. See ProcessBuilder.start() and Process.waitFor()InterruptedException - if an error occurred executing the command. See ProcessBuilder.start()
and Process.waitFor()ProcessBuilder.start(),
Process.waitFor()protected void saveIssues(org.sonar.api.batch.fs.InputFile inputFile,
String output,
org.sonar.api.batch.sensor.SensorContext context)
IllegaArgumentException
is raised.inputFile - the file that has the issues to be savedoutput - JSON output received from shellcheckcontext - the execution sensor context (taken from the method execute(SensorContext) of the child class)protected void saveIssue(org.sonar.api.batch.sensor.SensorContext context,
org.sonar.api.batch.fs.InputFile inputFile,
int line,
String ruleId,
String message)
context - the contextinputFile - the file where the issue was foundline - the line where the issue was foundruleId - the Id of the rule that raised the issuemessage - a message describing the issueprotected org.sonar.api.rule.RuleKey getRuleKey(org.sonar.api.batch.sensor.SensorContext context,
String ruleId)
RuleKey identified as the passed ruleId or null if no corresponding active
rule has been foundcontext - the sensor context (that contains the active rules)ruleId - the rule Id (corresponding to the searched RuleKey)RuleKey or null if no active rule has been foundCopyright © 2018–2019. All rights reserved.