@Override public void reportSingleLineComment(String type, int startLineNo, int startColNo) { reportSingleLineComment(startLineNo, startColNo); }
/** * Report the location of a C++ style comment. * @param startLineNo the starting line number * @param startColNo the starting column number * @deprecated Use {@link #reportSingleLineComment(int, int)} instead. **/ @Deprecated public void reportCppComment(int startLineNo, int startColNo) { reportSingleLineComment(startLineNo, startColNo); }
@Test public void testSinglelineCommentNotIntersect() { // just to make UT coverage 100% final FileContents fileContents = new FileContents( new FileText(new File("filename"), Collections.singletonList(" // "))); fileContents.reportSingleLineComment(1, 2); assertFalse("Should return false when there is no intersection", fileContents.hasIntersectionWithComment(1, 0, 1, 1)); }
@Test public void testSinglelineCommentIntersect() { // just to make UT coverage 100% final FileContents fileContents = new FileContents( new FileText(new File("filename"), Collections.singletonList(" // "))); fileContents.reportSingleLineComment(1, 2); assertTrue("Should return true when comments intersect", fileContents.hasIntersectionWithComment(1, 5, 1, 6)); }
@Test public void testTagsAreClearedEachRun() { final SuppressWithNearbyCommentFilter suppressionCommentFilter = new SuppressWithNearbyCommentFilter(); final FileContents contents = new FileContents("filename", "//SUPPRESS CHECKSTYLE ignore", "line2"); contents.reportSingleLineComment(1, 0); final TreeWalkerAuditEvent dummyEvent = new TreeWalkerAuditEvent(contents, "filename", new LocalizedMessage(1, null, null, null, null, Object.class, null), null); suppressionCommentFilter.accept(dummyEvent); final FileContents contents2 = new FileContents("filename2", "some line", "//SUPPRESS CHECKSTYLE ignore"); contents2.reportSingleLineComment(2, 0); final TreeWalkerAuditEvent dummyEvent2 = new TreeWalkerAuditEvent(contents2, "filename", new LocalizedMessage(1, null, null, null, null, Object.class, null), null); suppressionCommentFilter.accept(dummyEvent2); final List<SuppressionCommentFilter.Tag> tags = Whitebox.getInternalState(suppressionCommentFilter, "tags"); assertEquals("Invalid tags size", 1, tags.size()); }
@Test public void testTagsAreClearedEachRun() { final SuppressionCommentFilter suppressionCommentFilter = new SuppressionCommentFilter(); final FileContents contents = new FileContents("filename", "//CHECKSTYLE:OFF", "line2"); contents.reportSingleLineComment(1, 0); final TreeWalkerAuditEvent dummyEvent = new TreeWalkerAuditEvent(contents, "filename", new LocalizedMessage(1, null, null, null, null, Object.class, null), null); suppressionCommentFilter.accept(dummyEvent); final FileContents contents2 = new FileContents("filename2", "some line", "//CHECKSTYLE:OFF"); contents2.reportSingleLineComment(2, 0); final TreeWalkerAuditEvent dummyEvent2 = new TreeWalkerAuditEvent(contents2, "filename", new LocalizedMessage(1, null, null, null, null, Object.class, null), null); suppressionCommentFilter.accept(dummyEvent2); final List<SuppressionCommentFilter.Tag> tags = Whitebox.getInternalState(suppressionCommentFilter, "tags"); assertEquals("Invalid tags size", 1, tags.size()); }
@Test public void testFindNearestMatchDontAllowSameColumn() { final SuppressionCommentFilter suppressionCommentFilter = new SuppressionCommentFilter(); final FileContents contents = new FileContents("filename", "//CHECKSTYLE:OFF: ConstantNameCheck", "line2"); contents.reportSingleLineComment(1, 0); final TreeWalkerAuditEvent dummyEvent = new TreeWalkerAuditEvent(contents, "filename", new LocalizedMessage(1, null, null, null, null, Object.class, null), null); final boolean result = suppressionCommentFilter.accept(dummyEvent); assertFalse("Filter should not accept event", result); }
@Override public void reportSingleLineComment(String type, int startLineNo, int startColNo) { reportSingleLineComment(startLineNo, startColNo); }
/** * Report the location of a C++ style comment. * @param startLineNo the starting line number * @param startColNo the starting column number * @deprecated Use {@link #reportSingleLineComment(int, int)} instead. **/ @Deprecated public void reportCppComment(int startLineNo, int startColNo) { reportSingleLineComment(startLineNo, startColNo); }