test_class.declarator: RULE_ID1 = "ANSIBLE1"
test_class.modifier: private static final
test_class.original_string: private static final String RULE_ID1 = "ANSIBLE1";
test_class.type: String
test_class.var_name: RULE_ID1
test_class.declarator: RULE_ID2 = "EAnyCheck1"
test_class.modifier: private static final
test_class.original_string: private static final String RULE_ID2 = "EAnyCheck1";
test_class.type: String
test_class.var_name: RULE_ID2
test_class.declarator: RULE_ID3 = "EAnyCheck2"
test_class.modifier: private static final
test_class.original_string: private static final String RULE_ID3 = "EAnyCheck2";
test_class.type: String
test_class.var_name: RULE_ID3
test_class.declarator: ruleKey1 = RuleKey.of(AnsibleCheckRepository.REPOSITORY_KEY, RULE_ID1)
test_class.modifier: private final
test_class.original_string: private final RuleKey ruleKey1 = RuleKey.of(AnsibleCheckRepository.REPOSITORY_KEY, RULE_ID1);
test_class.type: RuleKey
test_class.var_name: ruleKey1
test_class.declarator: ruleKey2 = RuleKey.of(AnsibleCheckRepository.REPOSITORY_KEY, RULE_ID2)
test_class.modifier: private final
test_class.original_string: private final RuleKey ruleKey2 = RuleKey.of(AnsibleCheckRepository.REPOSITORY_KEY, RULE_ID2);
test_class.type: RuleKey
test_class.var_name: ruleKey2
test_class.declarator: ruleKey3 = RuleKey.of(AnsibleCheckRepository.REPOSITORY_KEY, RULE_ID3)
test_class.modifier: private final
test_class.original_string: private final RuleKey ruleKey3 = RuleKey.of(AnsibleCheckRepository.REPOSITORY_KEY, RULE_ID3);
test_class.type: RuleKey
test_class.var_name: ruleKey3
test_class.declarator: sensor
test_class.modifier: private
test_class.original_string: private MySensor sensor;
test_class.type: MySensor
test_class.var_name: sensor
test_class.declarator: context
test_class.modifier: private
test_class.original_string: private SensorContextTester context;
test_class.type: SensorContextTester
test_class.var_name: context
test_class.declarator: temporaryFolder = new TemporaryFolder()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public TemporaryFolder temporaryFolder = new TemporaryFolder();
test_class.type: TemporaryFolder
test_class.var_name: temporaryFolder
test_class.declarator: logTester = new LogTester()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public LogTester logTester = new LogTester();
test_class.type: LogTester
test_class.var_name: logTester
test_class.file: sonar-ansible-api/src/test/java/com/github/sbaudoin/sonar/plugins/ansible/rules/AbstractAnsibleSensorTest.java
test_class.identifier: AbstractAnsibleSensorTest
test_case.body: @Test
      public void testExecuteWithAnsibleLintWinthoutConf() throws IOException {
          InputFile playbook1 = Utils.getInputFile("playbooks/playbook1.yml");
          context.fileSystem().add(playbook1);
  
          if (System.getProperty("os.name").toLowerCase().contains("windows")) {
              context.settings().appendProperty(AnsibleSettings.ANSIBLE_LINT_PATH_KEY,
                      new File(getClass().getResource("/scripts/echo_as_issue.cmd").getFile()).getAbsolutePath());
          } else {
              String path = new File(getClass().getResource("/scripts/echo_as_issue.sh").getFile()).getAbsolutePath();
              context.settings().appendProperty(AnsibleSettings.ANSIBLE_LINT_PATH_KEY, path);
              setShellRights(path);
          }
  
          sensor.executeWithAnsibleLint(context, null);
          Collection<Issue> issues = context.allIssues();
          assertEquals(1, issues.size());
          assertTrue(issueExists(issues, ruleKey1, playbook1, 2, "-p --nocolor " + Pattern.quote(new File(playbook1.uri()).getAbsolutePath())));
      }
test_case.class_method_signature: AbstractAnsibleSensorTest.testExecuteWithAnsibleLintWinthoutConf()
test_case.full_signature: @Test public void testExecuteWithAnsibleLintWinthoutConf()
test_case.identifier: testExecuteWithAnsibleLintWinthoutConf
test_case.invocations: getInputFile add fileSystem contains toLowerCase getProperty appendProperty settings getAbsolutePath getFile getResource getClass getAbsolutePath getFile getResource getClass appendProperty settings setShellRights executeWithAnsibleLint allIssues assertEquals size assertTrue issueExists quote getAbsolutePath uri
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testExecuteWithAnsibleLintWinthoutConf()
focal_class.declarator: LOGGER = Loggers.get(AbstractAnsibleSensor.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = Loggers.get(AbstractAnsibleSensor.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: fileSystem
focal_class.modifier: protected final
focal_class.original_string: protected final FileSystem fileSystem;
focal_class.type: FileSystem
focal_class.var_name: fileSystem
focal_class.declarator: mainFilesPredicate
focal_class.modifier: protected final
focal_class.original_string: protected final FilePredicate mainFilesPredicate;
focal_class.type: FilePredicate
focal_class.var_name: mainFilesPredicate
focal_class.declarator: allIssues = new HashMap<>()
focal_class.modifier: protected final
focal_class.original_string: protected final Map<URI, Set<String>> allIssues = new HashMap<>();
focal_class.type: Map<URI, Set<String>>
focal_class.var_name: allIssues
focal_class.declarator: scannedFiles = new HashSet<>()
focal_class.modifier: protected final
focal_class.original_string: protected final Set<InputFile> scannedFiles = new HashSet<>();
focal_class.type: Set<InputFile>
focal_class.var_name: scannedFiles
focal_class.file: sonar-ansible-api/src/main/java/com/github/sbaudoin/sonar/plugins/ansible/rules/AbstractAnsibleSensor.java
focal_class.identifier: AbstractAnsibleSensor
focal_class.interfaces: implements Sensor
focal_class.class_method_signature: AbstractAnsibleSensor.AbstractAnsibleSensor(FileSystem fileSystem)
focal_class.full_signature: protected  AbstractAnsibleSensor(FileSystem fileSystem)
focal_class.identifier: AbstractAnsibleSensor
focal_class.modifiers: protected
focal_class.parameters: (FileSystem fileSystem)
focal_class.signature:  AbstractAnsibleSensor(FileSystem fileSystem)
focal_class.class_method_signature: AbstractAnsibleSensor.executeWithAnsibleLint(SensorContext context, @Nullable List<String> extraAnsibleLintArgs)
focal_class.full_signature: protected void executeWithAnsibleLint(SensorContext context, @Nullable List<String> extraAnsibleLintArgs)
focal_class.identifier: executeWithAnsibleLint
focal_class.modifiers: protected
focal_class.parameters: (SensorContext context, @Nullable List<String> extraAnsibleLintArgs)
focal_class.return: void
focal_class.signature: void executeWithAnsibleLint(SensorContext context, @Nullable List<String> extraAnsibleLintArgs)
focal_class.class_method_signature: AbstractAnsibleSensor.getAnsibleLintPath(SensorContext context)
focal_class.full_signature: protected String getAnsibleLintPath(SensorContext context)
focal_class.identifier: getAnsibleLintPath
focal_class.modifiers: protected
focal_class.parameters: (SensorContext context)
focal_class.return: String
focal_class.signature: String getAnsibleLintPath(SensorContext context)
focal_class.class_method_signature: AbstractAnsibleSensor.getAnsibleLintConfPath(SensorContext context)
focal_class.full_signature: protected String getAnsibleLintConfPath(SensorContext context)
focal_class.identifier: getAnsibleLintConfPath
focal_class.modifiers: protected
focal_class.parameters: (SensorContext context)
focal_class.return: String
focal_class.signature: String getAnsibleLintConfPath(SensorContext context)
focal_class.class_method_signature: AbstractAnsibleSensor.executeCommand(List<String> command, List<String> stdOut, List<String> errOut)
focal_class.full_signature: protected int executeCommand(List<String> command, List<String> stdOut, List<String> errOut)
focal_class.identifier: executeCommand
focal_class.modifiers: protected
focal_class.parameters: (List<String> command, List<String> stdOut, List<String> errOut)
focal_class.return: int
focal_class.signature: int executeCommand(List<String> command, List<String> stdOut, List<String> errOut)
focal_class.class_method_signature: AbstractAnsibleSensor.registerIssue(String rawIssue)
focal_class.full_signature: protected boolean registerIssue(String rawIssue)
focal_class.identifier: registerIssue
focal_class.modifiers: protected
focal_class.parameters: (String rawIssue)
focal_class.return: boolean
focal_class.signature: boolean registerIssue(String rawIssue)
focal_class.class_method_signature: AbstractAnsibleSensor.saveIssues(SensorContext context)
focal_class.full_signature: protected void saveIssues(SensorContext context)
focal_class.identifier: saveIssues
focal_class.modifiers: protected
focal_class.parameters: (SensorContext context)
focal_class.return: void
focal_class.signature: void saveIssues(SensorContext context)
focal_class.class_method_signature: AbstractAnsibleSensor.saveIssue(SensorContext context, InputFile inputFile, int line, String ruleId, String message)
focal_class.full_signature: protected void saveIssue(SensorContext context, InputFile inputFile, int line, String ruleId, String message)
focal_class.identifier: saveIssue
focal_class.modifiers: protected
focal_class.parameters: (SensorContext context, InputFile inputFile, int line, String ruleId, String message)
focal_class.return: void
focal_class.signature: void saveIssue(SensorContext context, InputFile inputFile, int line, String ruleId, String message)
focal_class.class_method_signature: AbstractAnsibleSensor.getRuleKey(SensorContext context, String ruleId)
focal_class.full_signature: protected RuleKey getRuleKey(SensorContext context, String ruleId)
focal_class.identifier: getRuleKey
focal_class.modifiers: protected
focal_class.parameters: (SensorContext context, String ruleId)
focal_class.return: RuleKey
focal_class.signature: RuleKey getRuleKey(SensorContext context, String ruleId)
focal_method.body: protected void executeWithAnsibleLint(SensorContext context, @Nullable List<String> extraAnsibleLintArgs) {
          LOGGER.debug("Ansible sensor executed with context: " + context);
  
          // Skip analysis if no rules enabled from this plugin
          if (context.activeRules().findByRepository(AnsibleCheckRepository.REPOSITORY_KEY).isEmpty()) {
              LOGGER.info("No active rules found for this plugin, skipping.");
              return;
          }
  
          for (InputFile inputFile : fileSystem.inputFiles(mainFilesPredicate)) {
              LOGGER.debug("Analyzing file: " + inputFile.filename());
              scannedFiles.add(inputFile);
  
              // Build ansible-lint command
              List<String> command = new ArrayList<>();
              command.addAll(Arrays.asList(getAnsibleLintPath(context), "-p", "--nocolor"));
              String confPath = getAnsibleLintConfPath(context);
              if (!"".equals(confPath.trim())) {
                  command.addAll(Arrays.asList("-c", confPath));
              }
              if (extraAnsibleLintArgs != null) {
                  command.addAll(extraAnsibleLintArgs);
              }
              command.add(new File(inputFile.uri()).getAbsolutePath());
  
              // Execute Ansible Lint and get a parsable output
              List<String> output = new ArrayList<>();
              List<String> error = new ArrayList<>();
              try {
                  executeCommand(command, output, error);
              } catch (InterruptedException e) {
                  Thread.currentThread().interrupt();
                  return;
              } catch (IOException e) {
                  return;
              }
              if (!error.isEmpty()) {
                  LOGGER.warn("Errors happened during analysis:{}{}",
                          System.getProperty("line.separator"),
                          String.join(System.getProperty("line.separator"), error)
                  );
              }
  
              LOGGER.debug(output.size() + " issue(s) found");
              // Parse output and register all issues: as ansible-lint processes only playbooks but returns issues related to
              // used roles, we need to save all issues first before being able to get role issues and save them
              output.forEach(this::registerIssue);
          }
  
          // Save all found issues
          saveIssues(context);
      }
focal_method.class_method_signature: AbstractAnsibleSensor.executeWithAnsibleLint(SensorContext context, @Nullable List<String> extraAnsibleLintArgs)
focal_method.full_signature: protected void executeWithAnsibleLint(SensorContext context, @Nullable List<String> extraAnsibleLintArgs)
focal_method.identifier: executeWithAnsibleLint
focal_method.invocations: debug isEmpty findByRepository activeRules info inputFiles debug filename add addAll asList getAnsibleLintPath getAnsibleLintConfPath equals trim addAll asList addAll add getAbsolutePath uri executeCommand interrupt currentThread isEmpty warn getProperty join getProperty debug size forEach saveIssues
focal_method.modifiers: protected
focal_method.parameters: (SensorContext context, @Nullable List<String> extraAnsibleLintArgs)
focal_method.return: void
focal_method.signature: void executeWithAnsibleLint(SensorContext context, @Nullable List<String> extraAnsibleLintArgs)