*/
package org.sonar.java.recognizer;
-import java.util.HashSet;
-import java.util.Set;
+import com.google.common.collect.Sets;
+import org.sonar.squid.recognizer.*;
-import org.sonar.squid.recognizer.CamelCaseDetector;
-import org.sonar.squid.recognizer.ContainsDetector;
-import org.sonar.squid.recognizer.Detector;
-import org.sonar.squid.recognizer.EndWithDetector;
-import org.sonar.squid.recognizer.KeywordsDetector;
-import org.sonar.squid.recognizer.LanguageFootprint;
+import java.util.Set;
-public class JavaFootprint implements LanguageFootprint {
+public final class JavaFootprint implements LanguageFootprint {
- private final Set<Detector> detectors = new HashSet<Detector>();
+ private final Set<Detector> detectors = Sets.newHashSet();
public JavaFootprint() {
detectors.add(new EndWithDetector(0.95, '}', ';', '{')); // NOSONAR Magic number is suitable in that case
detectors.add(new KeywordsDetector(0.7, "||", "&&")); // NOSONAR
- detectors.add(new KeywordsDetector(0.3, "public", "abstract", "class", "implements", "extends", "return","throw",// NOSONAR
+ detectors.add(new KeywordsDetector(0.3, "public", "abstract", "class", "implements", "extends", "return", "throw",// NOSONAR
"private", "protected", "enum", "continue", "assert", "package", "synchronized", "boolean", "this", "double", "instanceof",
"final", "interface", "static", "void", "long", "int", "float", "super", "true", "case:"));
detectors.add(new ContainsDetector(0.95, "++", "for(", "if(", "while(", "catch(", "switch(", "try{", "else{"));// NOSONAR
*/
package org.sonar.java.ast.visitor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.sonar.api.resources.InputFile;
import org.sonar.java.ast.JavaAstScanner;
import org.sonar.squid.api.SourceProject;
import org.sonar.squid.measures.Metric;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.*;
+
public class CommentVisitorTest {
private Squid squid;
}
@Test
- @Ignore("TODO")
- public void testCommentedOutFile() {
- SourceProject res = scan("/metrics/commentedCode", "org/foo/CommentedOutFile.java");
- }
-
- @Test
- @Ignore("TODO")
- public void shouldGuessPackageOfcommentedOutFile() {
- SourceProject res = scan("/metrics/commentedCode", "org/foo/CommentedOutFile.java");
+ public void shouldGetCommentedOutLinesOfEmptyFiles() {
+ scan("/metrics/commentedCode", "org/foo/CommentedOutFile.java");
+ SourceCode file = squid.search("org/foo/CommentedOutFile.java");
+ assertThat(file.getInt(Metric.COMMENTED_OUT_CODE_LINES), greaterThan(1));
}
@Test