use of org.sonar.api.issue.NoSonarFilter in project sonar-web by SonarSource.
the class WebSensorTest method setUp.
@Before
public void setUp() throws Exception {
WebRulesDefinition rulesDefinition = new WebRulesDefinition();
RulesDefinition.Context context = new RulesDefinition.Context();
rulesDefinition.define(context);
RulesDefinition.Repository repository = context.repository(WebRulesDefinition.REPOSITORY_KEY);
List<NewActiveRule> ar = new ArrayList<>();
for (RulesDefinition.Rule rule : repository.rules()) {
ar.add(new ActiveRulesBuilder().create(RuleKey.of(WebRulesDefinition.REPOSITORY_KEY, rule.key())));
}
ActiveRules activeRules = new DefaultActiveRules(ar);
CheckFactory checkFactory = new CheckFactory(activeRules);
FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
when(fileLinesContextFactory.createFor(Mockito.any(InputFile.class))).thenReturn(mock(FileLinesContext.class));
sensor = new WebSensor(new NoSonarFilter(), fileLinesContextFactory, checkFactory);
tester = SensorContextTester.create(TEST_DIR);
}
use of org.sonar.api.issue.NoSonarFilter in project sonar-web by SonarSource.
the class NoSonarScannerTest method scanNoSonar.
@Test
public void scanNoSonar() {
List<Node> nodeList = new PageLexer().parse(new StringReader("<table>\n<!-- //NOSONAR --><td>\n</table>"));
WebSourceCode webSourceCode = new WebSourceCode(new DefaultInputFile("key", "dummy.jsp"));
NoSonarFilter noSonarFilter = spy(new NoSonarFilter());
HtmlAstScanner pageScanner = new HtmlAstScanner(Collections.emptyList());
pageScanner.addVisitor(new NoSonarScanner(noSonarFilter));
pageScanner.scan(nodeList, webSourceCode, Charsets.UTF_8);
verify(noSonarFilter, times(1)).noSonarInFile(any(InputFile.class), isOnlyIgnoringLine2());
}
Aggregations