repo stringlengths 1 191 ⌀ | file stringlengths 23 351 | code stringlengths 0 5.32M | file_length int64 0 5.32M | avg_line_length float64 0 2.9k | max_line_length int64 0 288k | extension_type stringclasses 1 value |
|---|---|---|---|---|---|---|
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/constructorcallsoverridablemethod/Thing.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.errorprone.constructorcallsoverridablemethod;
public interface Thing {
String getName();
void setName(String name);
}
| 259 | 20.666667 | 88 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/constructorcallsoverridablemethod/AbstractThing.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.errorprone.constructorcallsoverridablemethod;
public abstract class AbstractThing implements Thing {
protected AbstractThing(Thing original) {
setName(original.getName());
}
@Override
public void setName(String name) { }
@Override
public String getName() {
return "";
}
}
| 450 | 21.55 | 88 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/HasAnnotationXPathTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Rule;
/**
* @author Clément Fournier
* @since 7.0.0
*/
class HasAnnotationXPathTest extends BaseXPathFunctionTest {
@Test
void testHasAnnotation() {
Rule rule = makeXpathRuleFromXPath("//MethodDeclaration[pmd-java:hasAnnotation('java.lang.Override')]");
String code = "interface O { @Override void foo(); }";
assertFinds(rule, 1, code);
}
@Test
void testHasAnnotationNonQual() {
Rule rule = makeXpathRuleFromXPath("//MethodDeclaration[pmd-java:hasAnnotation('Override')]");
String code = "interface O { @Override void foo(); }";
//does not match
assertFinds(rule, 0, code);
}
@Test
void testWrongTypeReturnsFalse() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceBody[pmd-java:hasAnnotation('java.lang.Override')]");
String code = "interface O { @Override void foo(); }";
assertFinds(rule, 0, code);
}
}
| 1,152 | 24.622222 | 115 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/XPathMetricFunctionTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Rule;
/**
* @author Clément Fournier
* @since 6.0.0
*/
class XPathMetricFunctionTest extends BaseXPathFunctionTest {
@Test
void testWellFormedClassMetricRule() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceDeclaration[pmd-java:metric('NCSS') > 0]");
String code = "class Foo { Foo() {} void bar() {}}";
assertFinds(rule, 1, code);
}
@Test
void testWellFormedOperationMetricRule() {
Rule rule = makeXpathRuleFromXPath("//ConstructorDeclaration[pmd-java:metric('CYCLO') > 1]");
String code = "class Goo { Goo() {if(true){}} }";
assertFinds(rule, 1, code);
}
@Test
void testBadCase() {
Rule rule = makeXpathRuleFromXPath("//ConstructorDeclaration[pmd-java:metric('cYclo') > 1]");
String code = "class Hoo { Hoo() {if(true){}} }";
assertFinds(rule, 1, code);
}
@Test
void testNonexistentMetric() {
testWithExpectedException(
"//ConstructorDeclaration[pmd-java:metric('FOOBAR') > 1]",
"class Joo { Joo() {if(true){}} }",
e -> assertThat(e.getMessage(), containsString(MetricFunction.badMetricKeyMessage("FOOBAR"))));
}
@Test
void testIfStmt() {
Rule rule = makeXpathRuleFromXPath("//IfStatement[pmd-java:metric('NCSS') = 1]");
String code = "class Hoo { Hoo() {if(true){}} }";
assertFinds(rule, 1, code);
}
@Test
void testWrongNodeTypeMeansEmptySequence() {
Rule rule = makeXpathRuleFromXPath("//EnumDeclaration[not(pmd-java:metric('NPATH'))]");
String code = "enum Loo { FOO; }";
assertFinds(rule, 1, code);
}
}
| 1,996 | 25.986486 | 107 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/GetModifiersFunctionsTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase;
/**
* @author Clément Fournier
* @since 7.0.0
*/
class GetModifiersFunctionsTest extends BaseXPathFunctionTest {
@Test
void testEffectiveModifiers() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceDeclaration[pmd-java:modifiers() = ('public', 'abstract')]");
String code = "interface O { class Foo { } }";
assertFinds(rule, 2, code);
}
@Test
void testExplicitModifiers() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceDeclaration[pmd-java:explicitModifiers() = ('public', 'abstract')]");
String code = "interface O { class Foo { } }";
assertFinds(rule, 0, code);
}
@Test
void testNotAccessNodeReturnsEmptySequence() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceBody[pmd-java:modifiers()]");
String code = "interface O { class Foo { } }";
assertFinds(rule, 0, code);
}
@Test
void testStaticTypeError() {
testWithExpectedStaticException(
"//MethodDeclaration[(., .) is pmd-java:modifiers()]",
e -> {
assertThat(e.getMessage(), containsString("Type error"));
assertThat(e.getPhase(), equalTo(Phase.INITIALIZATION));
});
}
}
| 1,706 | 26.532258 | 131 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/MatchesSignatureXPathTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.lang.LanguageProcessor;
import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException;
import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase;
/**
* @author Clément Fournier
* @since 7.0.0
*/
class MatchesSignatureXPathTest extends BaseXPathFunctionTest {
@Test
void testMatchSig1() {
Rule rule = makeXpathRuleFromXPath("//MethodCall[pmd-java:matchesSig('_#equals(java.lang.Object)')]");
assertFinds(rule, 1, "class O { { this.equals(\"\"); } }");
assertFinds(rule, 0, "class O { { this.equals(\"\", 2); } void equals(String i, int a) {}}");
}
@Test
void testMatchSigWithReceiver() {
Rule rule = makeXpathRuleFromXPath("//MethodCall[pmd-java:matchesSig('java.lang.Enum#equals(java.lang.Object)')]");
assertFinds(rule, 1, "enum O {; { this.equals(\"\"); } }");
assertFinds(rule, 0, "enum O {; { \"\".equals(\"\"); } }");
}
@Test
void testMatchSigUnresolved() {
Rule rule = makeXpathRuleFromXPath("//MethodCall[pmd-java:matchesSig('java.lang.String#foobar()')]");
assertFinds(rule, 0, "enum O {; { \"\".foobar(); } }");
}
@Test
void testMatchSigNoName() {
Rule rule = makeXpathRuleFromXPath("//MethodCall[pmd-java:matchesSig('_#_(int,int)')]");
assertFinds(rule, 2, "enum O {; { \"\".substring(1, 2); this.foo(1, 'c');} void foo(int a, int b) {} }");
}
@Test
void testMatchSigWrongTypeReturnsFalse() {
Rule rule = makeXpathRuleFromXPath("//EnumDeclaration[pmd-java:matchesSig('_#_(int,int)')]");
assertFinds(rule, 0, "enum O {; { \"\".substring(1, 2); this.foo(1, 'c');} void foo(int a, int b) {} }");
}
@Test
void testMatchInvalidSig() throws Exception {
Rule rule = makeXpathRuleFromXPath("//*[pmd-java:matchesSig('_#')]");
try (LanguageProcessor lp = java.newProcessor()) {
PmdXPathException e = assertThrows(PmdXPathException.class, () -> rule.initialize(lp));
assertEquals(Phase.INITIALIZATION, e.getPhase());
}
}
}
| 2,435 | 31.48 | 123 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/TypeIsFunctionTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Rule;
/**
* @author Clément Fournier
* @since 7.0.0
*/
class TypeIsFunctionTest extends BaseXPathFunctionTest {
@Test
void testHasAnnotation() {
Rule rule = makeXpathRuleFromXPath("//Annotation[pmd-java:typeIs('java.lang.Override')]");
assertFinds(rule, 1, "interface O { @Override void foo(); }");
}
@Test
void testHasAnnotationNonQual() {
Rule rule = makeXpathRuleFromXPath("//Annotation[pmd-java:typeIs('Override')]");
//does not match
assertFinds(rule, 0, "interface O { @Override void foo(); }");
}
@Test
void testTypeIsArray() {
Rule rule = makeXpathRuleFromXPath("//*[pmd-java:typeIs('int[]')]");
// ArrayType + VariableDeclaratorId
assertFinds(rule, 2, "class K { int[] i; }");
}
@Test
void testWrongTypeReturnsFalse() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceBody[pmd-java:typeIs('java.lang.Override')]");
assertFinds(rule, 0, "interface O { @Override void foo(); }");
}
}
| 1,250 | 24.530612 | 108 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/BaseXPathFunctionTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.function.Consumer;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.lang.LanguageProcessor;
import net.sourceforge.pmd.lang.ast.FileAnalysisException;
import net.sourceforge.pmd.lang.ast.test.TestUtilsKt;
import net.sourceforge.pmd.lang.java.BaseParserTest;
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException;
import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase;
import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
/**
* @author Clément Fournier
* @since 7.0.0
*/
class BaseXPathFunctionTest extends BaseParserTest {
private static final String VIOLATION_MESSAGE = "violation";
private static final String RULE_NAME_PLACEHOLDER = "$rule_name";
private @NonNull Report executeRule(Rule rule, String code) {
return java.executeRule(rule, code);
}
protected Rule makeXpathRuleFromXPath(String xpath) {
XPathRule rule = new XPathRule(XPathVersion.DEFAULT, xpath);
rule.setName("$rule_name");
rule.setMessage(VIOLATION_MESSAGE);
rule.setLanguage(JavaLanguageModule.getInstance());
return rule;
}
protected void assertFinds(Rule rule, int numViolations, String code) {
Report report = executeRule(rule, code);
TestUtilsKt.assertSize(report, numViolations);
}
protected void testWithExpectedException(String xpath,
String code,
Consumer<? super PmdXPathException> exceptionSpec) {
Rule rule = makeXpathRuleFromXPath(xpath);
FileAnalysisException thrown = assertThrows(FileAnalysisException.class, () -> executeRule(rule, code));
assertThat(thrown.getCause(), instanceOf(PmdXPathException.class));
PmdXPathException cause = (PmdXPathException) thrown.getCause();
exceptionSpec.accept(cause);
assertThat(cause.getRuleName(), equalTo(RULE_NAME_PLACEHOLDER));
}
protected void testWithExpectedStaticException(String xpath,
Consumer<? super PmdXPathException> exceptionSpec) {
Rule rule = makeXpathRuleFromXPath(xpath);
try (LanguageProcessor proc = java.newProcessor()) {
PmdXPathException thrown = assertThrows(PmdXPathException.class, () -> rule.initialize(proc));
exceptionSpec.accept(thrown);
assertThat(thrown.getPhase(), equalTo(Phase.INITIALIZATION));
assertThat(thrown.getRuleName(), equalTo(RULE_NAME_PLACEHOLDER));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| 3,212 | 35.101124 | 112 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/xpath/internal/NodeIsFunctionTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException.Phase;
/**
* @author Clément Fournier
* @since 7.0.0
*/
class NodeIsFunctionTest extends BaseXPathFunctionTest {
@Test
void testWellFormedNodeName() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceDeclaration[pmd-java:nodeIs('ClassOrInterfaceDeclaration')]");
String code = "class Foo { Foo() {} void bar() {}}";
assertFinds(rule, 1, code);
}
@Test
void testNodeNameStaticallyUnknown() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceDeclaration[pmd-java:nodeIs(name())]");
String code = "class Foo { Foo() {} void bar() {}}";
assertFinds(rule, 1, code);
}
@Test
void testWellFormedNodeNameForSupertype() {
Rule rule = makeXpathRuleFromXPath("//ClassOrInterfaceDeclaration[pmd-java:nodeIs('AnyTypeDeclaration')]");
String code = "class Foo { Foo() {} void bar() {}}";
assertFinds(rule, 1, code);
}
@Test
void testNonExistentNodeName() {
// note that this would fail with a type error (boolean > integer)
// if nodeIs fails to fail
testWithExpectedStaticException(
"//MethodDeclaration[pmd-java:nodeIs('ohio') > 1]",
e -> {
assertThat(e.getMessage(), containsString("ASTohio"));
});
}
@Test
void testNonExistentNodeNameStaticallyUnknown() {
testWithExpectedException(
"//MethodDeclaration[pmd-java:nodeIs(name() || 'qqq')]",
"class Moo { void foo() {if(true){}} }",
e -> {
assertThat(e.getMessage(), containsString("MethodDeclarationqqq"));
assertThat(e.getPhase(), equalTo(Phase.EVALUATION));
});
}
}
| 2,170 | 27.565789 | 124 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ReplaceVectorWithListTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ReplaceVectorWithListTest extends PmdRuleTst {
// no additional unit tests
}
| 289 | 23.166667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitAssertionsShouldIncludeMessageTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnitAssertionsShouldIncludeMessageTest extends PmdRuleTst {
// no additional unit tests
}
| 303 | 24.333333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitTestsShouldIncludeAssertTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnitTestsShouldIncludeAssertTest extends PmdRuleTst {
// no additional unit tests
}
| 297 | 23.833333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ForLoopVariableCountTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ForLoopVariableCountTest extends PmdRuleTst {
// no additional unit tests
}
| 288 | 23.083333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitTestContainsTooManyAssertsTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnitTestContainsTooManyAssertsTest extends PmdRuleTst {
// no additional unit tests
}
| 299 | 24 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedPrivateMethodTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UnusedPrivateMethodTest extends PmdRuleTst {
// no additional unit tests
}
| 287 | 23 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/CheckResultSetTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class CheckResultSetTest extends PmdRuleTst {
// no additional unit tests
}
| 282 | 22.583333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnit4SuitesShouldUseSuiteAnnotationTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnit4SuitesShouldUseSuiteAnnotationTest extends PmdRuleTst {
// no additional unit tests
}
| 304 | 24.416667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedLocalVariableTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UnusedLocalVariableTest extends PmdRuleTst {
// no additional unit tests
}
| 287 | 23 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningCatchVariablesTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidReassigningCatchVariablesTest extends PmdRuleTst {
// no additional unit tests
}
| 298 | 23.916667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidUsingHardCodedIPTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidUsingHardCodedIPTest extends PmdRuleTst {
// no additional unit tests
}
| 289 | 23.166667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnit4TestShouldUseBeforeAnnotationTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnit4TestShouldUseBeforeAnnotationTest extends PmdRuleTst {
// no additional unit tests
}
| 303 | 24.333333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AbstractClassWithoutAbstractMethodTest extends PmdRuleTst {
// no additional unit tests
}
| 302 | 24.25 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/LiteralsFirstInComparisonsTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class LiteralsFirstInComparisonsTest extends PmdRuleTst {
// no additional unit tests
}
| 294 | 23.583333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/GuardLogStatementTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class GuardLogStatementTest extends PmdRuleTst {
// no additional unit tests
}
| 285 | 22.833333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ArrayIsStoredDirectlyTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ArrayIsStoredDirectlyTest extends PmdRuleTst {
// no additional unit tests
}
| 289 | 23.166667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/PrimitiveWrapperInstantiationTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class PrimitiveWrapperInstantiationTest extends PmdRuleTst {
// no additional unit tests
}
| 297 | 23.833333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidMessageDigestFieldTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidMessageDigestFieldTest extends PmdRuleTst {
// no additional unit tests
}
| 291 | 23.333333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/SimplifiableTestAssertionTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class SimplifiableTestAssertionTest extends PmdRuleTst {
// no additional unit tests
}
| 293 | 23.5 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnit4TestShouldUseAfterAnnotationTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnit4TestShouldUseAfterAnnotationTest extends PmdRuleTst {
// no additional unit tests
}
| 302 | 24.25 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidStringBufferFieldTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidStringBufferFieldTest extends PmdRuleTst {
// no additional unit tests
}
| 290 | 23.25 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningLoopVariablesTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidReassigningLoopVariablesTest extends PmdRuleTst {
// no additional unit tests
}
| 297 | 23.833333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/PreserveStackTraceTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class PreserveStackTraceTest extends PmdRuleTst {
// no additional unit tests
}
| 286 | 22.916667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UseVarargsTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UseVarargsTest extends PmdRuleTst {
// no additional unit tests
}
| 278 | 22.25 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DoubleBraceInitializationTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class DoubleBraceInitializationTest extends PmdRuleTst {
// no additional unit tests
}
| 292 | 23.416667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ConstantsInInterfaceTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ConstantsInInterfaceTest extends PmdRuleTst {
// no additional unit tests
}
| 288 | 23.083333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnit5TestShouldBePackagePrivateTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnit5TestShouldBePackagePrivateTest extends PmdRuleTst {
// no additional unit tests
}
| 300 | 24.083333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedFormalParameterTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UnusedFormalParameterTest extends PmdRuleTst {
// no additional unit tests
}
| 289 | 23.166667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnit4TestShouldUseTestAnnotationTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnit4TestShouldUseTestAnnotationTest extends PmdRuleTst {
// no additional unit tests
}
| 301 | 24.166667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UseStandardCharsetsTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UseStandardCharsetsTest extends PmdRuleTst {
// no additional unit tests
}
| 287 | 23 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/LooseCouplingTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class LooseCouplingTest extends PmdRuleTst {
// no additional unit tests
}
| 281 | 22.5 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UseTryWithResourcesTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UseTryWithResourcesTest extends PmdRuleTst {
// no additional unit tests
}
| 287 | 23 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UseCollectionIsEmptyTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UseCollectionIsEmptyTest extends PmdRuleTst {
// no additional unit tests
}
| 288 | 23.083333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedPrivateFieldTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UnusedPrivateFieldTest extends PmdRuleTst {
}
| 255 | 20.333333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ReplaceHashtableWithMapTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ReplaceHashtableWithMapTest extends PmdRuleTst {
// no additional unit tests
}
| 291 | 23.333333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/OneDeclarationPerLineTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class OneDeclarationPerLineTest extends PmdRuleTst {
// no additional unit tests
}
| 289 | 23.166667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/SwitchStmtsShouldHaveDefaultTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class SwitchStmtsShouldHaveDefaultTest extends PmdRuleTst {
// no additional unit tests
}
| 296 | 23.75 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/SystemPrintlnTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class SystemPrintlnTest extends PmdRuleTst {
// no additional unit tests
}
| 281 | 22.5 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UnusedAssignmentTest extends PmdRuleTst {
// no additional unit tests
}
| 283 | 22.666667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitUseExpectedTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class JUnitUseExpectedTest extends PmdRuleTst {
// no additional unit tests
}
| 284 | 22.75 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorClassGenerationTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AccessorClassGenerationTest extends PmdRuleTst {
// no additional unit tests
}
| 291 | 23.333333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/MethodReturnsInternalArrayTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class MethodReturnsInternalArrayTest extends PmdRuleTst {
// no additional unit tests
}
| 294 | 23.583333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ForLoopCanBeForeachTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ForLoopCanBeForeachTest extends PmdRuleTst {
// no additional unit tests
}
| 287 | 23 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidPrintStackTraceTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidPrintStackTraceTest extends PmdRuleTst {
// no additional unit tests
}
| 288 | 23.083333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DefaultLabelNotLastInSwitchStmtTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class DefaultLabelNotLastInSwitchStmtTest extends PmdRuleTst {
// no additional unit tests
}
| 299 | 24 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/WhileLoopWithLiteralBooleanTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class WhileLoopWithLiteralBooleanTest extends PmdRuleTst {
// no additional unit tests
}
| 295 | 23.666667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/ReplaceEnumerationWithIteratorTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ReplaceEnumerationWithIteratorTest extends PmdRuleTst {
// no additional unit tests
}
| 298 | 23.916667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AccessorMethodGenerationTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AccessorMethodGenerationTest extends PmdRuleTst {
// no additional unit tests
}
| 292 | 23.416667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/MissingOverrideTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class MissingOverrideTest extends PmdRuleTst {
// no additional unit tests
}
| 283 | 22.666667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidReassigningParametersTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class AvoidReassigningParametersTest extends PmdRuleTst {
// no additional unit tests
}
| 294 | 23.583333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/unusedprivatefield/Value.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.unusedprivatefield;
/**
* Sample annotation used to test whether we correctly distinguish between {@code lombok.Value} and
* any other annotation called {@code Value}.
*/
public @interface Value {
}
| 349 | 24 | 99 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/SuperclassWithStatic.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.4.0
*/
public class SuperclassWithStatic {
protected SuperclassWithStatic() {
}
public static void fooBar(String f) {
}
}
| 353 | 14.391304 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/InterfaceWithBound.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
*
*/
public interface InterfaceWithBound<K extends Cloneable> {
void handle(K k);
}
| 260 | 15.3125 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/GenericWithOverloadsImpl.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTPackageDeclaration;
public class GenericWithOverloadsImpl implements GenericInterfaceWithOverloads<String, Integer> {
// a bridge method is generated for each of these that implement an interface method
@Override
public String visit(ASTCompilationUnit node, String data) {
return null;
}
@Override
public String visit(ASTPackageDeclaration node, String data) {
return null;
}
@Override
public String multi(ASTImportDeclaration node, String data, Integer integer) {
return null;
}
// this one is not overridden, no bridge
public String multi(ASTMethodDeclaration node, String data, Integer integer) {
return null;
}
@Override
public String multi(ASTPackageDeclaration node, String data, Integer integer) {
return null;
}
}
| 1,235 | 24.75 | 97 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/EnumWithInterfaces.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.2.0
*/
public enum EnumWithInterfaces implements InterfaceWithBound<int[]> {
Foo {
@Override
public void handle(int[] ints) {
super.handle(ints);
}
};
@Override
public void handle(int[] ints) {
}
}
| 466 | 17.68 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/CovariantReturnType.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public class CovariantReturnType extends AbstractClass {
@Override
String fun(String s) {
return "";
}
}
| 290 | 19.785714 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/SubclassWithStatic.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.4.0
*/
public class SubclassWithStatic extends SuperclassWithStatic {
public static void fooBar(String f) {
}
}
| 332 | 17.5 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/ConcreteClassTransitive.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.2.0
*/
public class ConcreteClassTransitive extends AbsClassWithInterface {
@Override
public void run() {
}
}
| 332 | 18.588235 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/CloneableInterfaceOverride.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.4.0
*/
public interface CloneableInterfaceOverride extends CloneableInterface {
@Override
CloneableInterface clone() throws CloneNotSupportedException;
}
| 372 | 22.3125 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/OptionTestCaseOneParam.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.1.0
*/
public class OptionTestCaseOneParam {
}
| 256 | 18.769231 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/SubclassWithGenericMethod.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public class SubclassWithGenericMethod extends AbstractClass {
@Override
public <T, R> R generic(T t, R r) {
return super.generic(t, r);
}
}
| 326 | 22.357143 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/SubclassPrivateNoOverride.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.4.0
*/
public class SubclassPrivateNoOverride extends SuperclassWithPrivate {
// No override
public void foo() {
}
}
| 340 | 17.944444 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/ConcreteClass.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.2.0
*/
public class ConcreteClass extends AbstractClass {
@Override
Object fun(String s) {
return null;
}
}
| 337 | 18.882353 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/AbstractBuilderMixedTypeVarOverride.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
import java.util.Collection;
public abstract class AbstractBuilderMixedTypeVarOverride<B extends AbstractBuilderMixedTypeVarOverride<B, T>, T> {
@SuppressWarnings("unchecked")
public B defaultValue(T val) {
return (B) this;
}
@SuppressWarnings("unchecked")
public B defaultValue2(T val) {
return (B) this;
}
public static final class ConcreteBuilder<V, C extends Collection<V>> extends AbstractBuilderMixedTypeVarOverride<ConcreteBuilder<V, C>, C> {
//@Override is wrong here: method does not override or implement a method from a supertype
public ConcreteBuilder<V, C> defaultValue(Collection<? extends V> val) {
return this;
}
@Override
public ConcreteBuilder<V, C> defaultValue2(C val) {
return this;
}
}
}
| 997 | 30.1875 | 145 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/AnonClassExample.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public class AnonClassExample {
static {
new Thread(new Runnable() {
// missing
public void run() {
}
}).start();
}
}
| 344 | 18.166667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/Option.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.2.0
*/
public class Option {
}
| 240 | 17.538462 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/EnumToString.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public enum EnumToString {
sub_EnumClazz {
// missing @Override
public String toString() {
return "test";
}
// missing @Override
public void notOverride() {
System.out.println("test");
}
};
// missing @Override
public String toString() {
return "test";
}
public void notOverride() {
System.out.println("test");
}
}
| 597 | 19.62069 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/AmbiguousOverload.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
import java.util.Comparator;
public class AmbiguousOverload implements Comparator<StringBuilder> {
// only one of those overloads is an override, and so there's only one bridge,
// so we can't choose the inherited overload
@Override
public int compare(StringBuilder o1, StringBuilder o2) {
return 0;
}
public int compare(String s, String s2) {
return 0;
}
}
| 576 | 18.896552 | 82 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/HierarchyWithSeveralBridges.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.ast.TypeNode;
public abstract class HierarchyWithSeveralBridges<T extends Node> {
abstract void foo(T node);
public abstract static class SubclassOne<T extends JavaNode> extends HierarchyWithSeveralBridges<T> {
@Override
abstract void foo(T node);
}
public abstract static class SubclassTwo<T extends TypeNode> extends SubclassOne<T> {
@Override
void foo(T node) {
}
}
public static class Concrete extends SubclassTwo<ASTPrimitiveType> {
// bridges: foo(AbstractJavaTypeNode), foo(JavaNode), foo(Node)
@Override
void foo(ASTPrimitiveType node) {
}
}
}
| 1,016 | 24.425 | 105 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/AbstractClass.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.2.0
*/
public abstract class AbstractClass {
Object fun(String s) {
return new Object();
}
public void arrayParams(String dflt, int[] keys, StringBuilder[] labels) {
}
public <T, R> R generic(T t, R r) {
return r;
}
}
| 473 | 16.555556 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/InterfaceWithNoSuperClass.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public interface InterfaceWithNoSuperClass {
@Override
String toString();
}
| 249 | 19.833333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/CloneableInterface.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.4.0
*/
interface CloneableInterface extends Cloneable {
// nothing to report, the method is not inherited
// https://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.6.3.4
CloneableInterface clone() throws CloneNotSupportedException;
}
| 467 | 28.25 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/SuperclassWithPrivate.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.4.0
*/
public class SuperclassWithPrivate {
private void foo() {
}
}
| 289 | 15.111111 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/EnumWithAnonClass.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.2.0
*/
public enum EnumWithAnonClass {
Foo {
// missing
public String toString() {
return super.toString();
}
// missing
public String getSomething() {
return null;
}
};
public Object getSomething() {
return null;
}
}
| 525 | 17.785714 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/AbsClassWithInterface.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
/**
* @author Clément Fournier
* @since 6.2.0
*/
public abstract class AbsClassWithInterface implements Runnable {
}
| 284 | 20.923077 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/GenericInterfaceWithOverloads.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTPackageDeclaration;
public interface GenericInterfaceWithOverloads<T, R extends Number> {
T visit(ASTCompilationUnit node, T data);
T visit(ASTPackageDeclaration node, T data);
T multi(ASTImportDeclaration node, T data, R r);
T multi(ASTPackageDeclaration node, T data, R r);
}
| 636 | 23.5 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/RunnableImpl.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public class RunnableImpl implements Runnable {
@Override
public void run() {
}
}
| 259 | 19 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/ConcreteClassArrayParams.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public class ConcreteClassArrayParams extends AbstractClass {
@Override
Object fun(String s) {
return null;
}
@Override
public void arrayParams(String dflt, int[] keys, StringBuilder[] labels) {
super.arrayParams(dflt, keys, labels);
}
}
| 444 | 22.421053 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/EmptyEnum.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride;
public enum EmptyEnum {
; // SUPPRESS CHECKSTYLE now
public static void main(String... args) {
method();
}
public static void method(int... a) {
System.out.println("1");
}
@SuppressWarnings("PMD.AvoidUsingShortType")
public static void method(short... b) {
System.out.println("2");
}
}
| 509 | 21.173913 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/a/PackagePrivateMethodRealExtend.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride.a;
public class PackagePrivateMethodRealExtend extends PackagePrivateMethod {
// package private, does override
@Override
void printMessage() {
System.out.println("Click");
}
}
| 364 | 23.333333 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/a/PackagePrivateMethod.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride.a;
public class PackagePrivateMethod {
// package private
void printMessage() {
System.out.println("Click");
}
}
| 296 | 20.214286 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/missingoverride/b/PackagePrivateMethodExtend.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride.b;
import net.sourceforge.pmd.lang.java.rule.bestpractices.missingoverride.a.PackagePrivateMethod;
public class PackagePrivateMethodExtend extends PackagePrivateMethod {
// does not override
void printMessage() {
System.out.println("Hack");
}
}
| 428 | 27.6 | 95 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/switchstmtsshouldhavedefault/SimpleEnum.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.switchstmtsshouldhavedefault;
/**
* @author Clément Fournier
* @since 6.5.0
*/
public enum SimpleEnum {
FOO,
BAR,
BZAZ
}
| 283 | 16.75 | 86 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/unusedprivatemethod/DashboardGraphInnateFilter.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.unusedprivatemethod;
/**
* Sample class
*/
public class DashboardGraphInnateFilter extends DashboardInnateFilter {
// yes, this is empty, it just need to be a subclass.
}
| 324 | 24 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/unusedprivatemethod/ClassWithPublicEnum.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.unusedprivatemethod;
/**
*
* ClassWithPublicEnum.java
*
* Copyright 2014 Expedia, Inc. All rights reserved.
* EXPEDIA PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/**
* Sample class with public enum to be used by tests for "UnusedPrivateMethod".
*
* @author <a href="mailto:svenz@expedia.com">Sven Zethelius</a>
*
*/
public class ClassWithPublicEnum {
public enum PublicEnum {
VALUE1, VALUE2
}
}
| 587 | 22.52 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/unusedprivatemethod/DashboardInnateFilter.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.bestpractices.unusedprivatemethod;
/**
* Sample class
*/
public class DashboardInnateFilter {
// yes, this class is empty. It is the base class for
// DashboardGraphInnateFilter_o
}
| 325 | 22.285714 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/StringToStringTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.performance;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class StringToStringTest extends PmdRuleTst {
// no additional unit tests
}
| 280 | 22.416667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveAppendsShouldReuseTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.performance;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ConsecutiveAppendsShouldReuseTest extends PmdRuleTst {
// no additional unit tests
}
| 295 | 23.666667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/UselessStringValueOfTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.performance;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class UselessStringValueOfTest extends PmdRuleTst {
// no additional unit tests
}
| 286 | 22.916667 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/TooFewBranchesForASwitchStatementTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.performance;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class TooFewBranchesForASwitchStatementTest extends PmdRuleTst {
// no additional unit tests
}
| 299 | 24 | 79 | java |
pmd | pmd-master/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/ConsecutiveLiteralAppendsTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.performance;
import net.sourceforge.pmd.testframework.PmdRuleTst;
class ConsecutiveLiteralAppendsTest extends PmdRuleTst {
// no additional unit tests
}
| 291 | 23.333333 | 79 | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.