@Test public void testActivationSonarLint() { SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(7, 3), SonarQubeSide.SERVER, SonarEdition.COMMUNITY); PHPRulesDefinition rulesDefinition = new PHPRulesDefinition(sonarRuntime); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository("php"); assertThat(repository).isNotNull(); assertThat(repository.name()).isEqualTo("SonarAnalyzer"); assertThat(repository.language()).isEqualTo("php"); assertThat(repository.rules()).hasSize(CheckList.getAllChecks().size()); List<Rule> activated = repository.rules().stream().filter(Rule::activatedByDefault).collect(Collectors.toList()); assertThat(activated).isNotEmpty(); assertThat(activated.size()).isLessThan(CheckList.getAllChecks().size()); }
@Override public void define(Context context) { NewRepository repository = context.createRepository(CheckList.REPOSITORY_KEY, Php.KEY).setName(REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH, PHPProfileDefinition.SONAR_WAY_PATH, sonarRuntime); ruleMetadataLoader.addRulesByAnnotatedClass(repository, new ArrayList<>(CheckList.getAllChecks())); repository.done(); }
PHPRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(CheckList.REPOSITORY_KEY, Php.KEY).setName(REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH, PHPProfileDefinition.SONAR_WAY_PATH, sonarRuntime); ruleMetadataLoader.addRulesByAnnotatedClass(repository, new ArrayList<>(CheckList.getAllChecks())); repository.done(); } }
PHPRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(CheckList.REPOSITORY_KEY, Php.KEY).setName(REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH, PHPProfileDefinition.SONAR_WAY_PATH, sonarRuntime); ruleMetadataLoader.addRulesByAnnotatedClass(repository, new ArrayList<>(CheckList.getAllChecks())); repository.done(); } PHPRulesDefinition(SonarRuntime sonarRuntime); }
PHPRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(CheckList.REPOSITORY_KEY, Php.KEY).setName(REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH, PHPProfileDefinition.SONAR_WAY_PATH, sonarRuntime); ruleMetadataLoader.addRulesByAnnotatedClass(repository, new ArrayList<>(CheckList.getAllChecks())); repository.done(); } PHPRulesDefinition(SonarRuntime sonarRuntime); @Override void define(Context context); }
PHPRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(CheckList.REPOSITORY_KEY, Php.KEY).setName(REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH, PHPProfileDefinition.SONAR_WAY_PATH, sonarRuntime); ruleMetadataLoader.addRulesByAnnotatedClass(repository, new ArrayList<>(CheckList.getAllChecks())); repository.done(); } PHPRulesDefinition(SonarRuntime sonarRuntime); @Override void define(Context context);  }