@Test public void define() { SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(7, 3), SonarQubeSide.SERVER); DartAnalyzerRulesDefinition rulesDefinition = new DartAnalyzerRulesDefinition(sonarRuntime); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository dartAnalyzerRepository = context.repository("dartanalyzer"); assertThat(dartAnalyzerRepository).isNotNull(); assertThat(dartAnalyzerRepository.name()).isEqualTo("dartanalyzer"); assertThat(dartAnalyzerRepository.language()).isEqualTo("dart"); assertThat(dartAnalyzerRepository.rules()).isNotEmpty(); }
@Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, Dart.KEY).setName(REPOSITORY_NAME); try(Reader reader = new InputStreamReader(getClass().getResourceAsStream(RULES_FILE), Charset.forName("UTF-8"))){ JSONArray slRules = (JSONArray) JSONValue.parse(reader); if(slRules != null){ for (Object obj : slRules) { JSONObject slRule = (JSONObject) obj; repository.createRule((String) slRule.get("key")) .setName((String) slRule.get("name")) .setSeverity((String) slRule.get("severity")) .setType(RuleType.valueOf((String) slRule.get("type"))) .setHtmlDescription((String) slRule.get("description")); } } } catch (IOException e) { LOGGER.error("Failed to load dartanalyzer rules", e); } SqaleXmlLoader.load(repository, "/fr/insideapp/sonarqube/dart/dartanalyzer/sqale-model.xml"); repository.done(); }
DartAnalyzerRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, Dart.KEY).setName(REPOSITORY_NAME); try(Reader reader = new InputStreamReader(getClass().getResourceAsStream(RULES_FILE), Charset.forName("UTF-8"))){ JSONArray slRules = (JSONArray) JSONValue.parse(reader); if(slRules != null){ for (Object obj : slRules) { JSONObject slRule = (JSONObject) obj; repository.createRule((String) slRule.get("key")) .setName((String) slRule.get("name")) .setSeverity((String) slRule.get("severity")) .setType(RuleType.valueOf((String) slRule.get("type"))) .setHtmlDescription((String) slRule.get("description")); } } } catch (IOException e) { LOGGER.error("Failed to load dartanalyzer rules", e); } SqaleXmlLoader.load(repository, "/fr/insideapp/sonarqube/dart/dartanalyzer/sqale-model.xml"); repository.done(); } }
DartAnalyzerRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, Dart.KEY).setName(REPOSITORY_NAME); try(Reader reader = new InputStreamReader(getClass().getResourceAsStream(RULES_FILE), Charset.forName("UTF-8"))){ JSONArray slRules = (JSONArray) JSONValue.parse(reader); if(slRules != null){ for (Object obj : slRules) { JSONObject slRule = (JSONObject) obj; repository.createRule((String) slRule.get("key")) .setName((String) slRule.get("name")) .setSeverity((String) slRule.get("severity")) .setType(RuleType.valueOf((String) slRule.get("type"))) .setHtmlDescription((String) slRule.get("description")); } } } catch (IOException e) { LOGGER.error("Failed to load dartanalyzer rules", e); } SqaleXmlLoader.load(repository, "/fr/insideapp/sonarqube/dart/dartanalyzer/sqale-model.xml"); repository.done(); } DartAnalyzerRulesDefinition(SonarRuntime sonarRuntime); }
DartAnalyzerRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, Dart.KEY).setName(REPOSITORY_NAME); try(Reader reader = new InputStreamReader(getClass().getResourceAsStream(RULES_FILE), Charset.forName("UTF-8"))){ JSONArray slRules = (JSONArray) JSONValue.parse(reader); if(slRules != null){ for (Object obj : slRules) { JSONObject slRule = (JSONObject) obj; repository.createRule((String) slRule.get("key")) .setName((String) slRule.get("name")) .setSeverity((String) slRule.get("severity")) .setType(RuleType.valueOf((String) slRule.get("type"))) .setHtmlDescription((String) slRule.get("description")); } } } catch (IOException e) { LOGGER.error("Failed to load dartanalyzer rules", e); } SqaleXmlLoader.load(repository, "/fr/insideapp/sonarqube/dart/dartanalyzer/sqale-model.xml"); repository.done(); } DartAnalyzerRulesDefinition(SonarRuntime sonarRuntime); @Override void define(Context context); }
DartAnalyzerRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, Dart.KEY).setName(REPOSITORY_NAME); try(Reader reader = new InputStreamReader(getClass().getResourceAsStream(RULES_FILE), Charset.forName("UTF-8"))){ JSONArray slRules = (JSONArray) JSONValue.parse(reader); if(slRules != null){ for (Object obj : slRules) { JSONObject slRule = (JSONObject) obj; repository.createRule((String) slRule.get("key")) .setName((String) slRule.get("name")) .setSeverity((String) slRule.get("severity")) .setType(RuleType.valueOf((String) slRule.get("type"))) .setHtmlDescription((String) slRule.get("description")); } } } catch (IOException e) { LOGGER.error("Failed to load dartanalyzer rules", e); } SqaleXmlLoader.load(repository, "/fr/insideapp/sonarqube/dart/dartanalyzer/sqale-model.xml"); repository.done(); } DartAnalyzerRulesDefinition(SonarRuntime sonarRuntime); @Override void define(Context context); static final String REPOSITORY_KEY; static final String REPOSITORY_NAME; static final String RULES_FILE; }