Search in sources :

Example 1 with BadMethodNameCheck

use of org.sonar.java.checks.naming.BadMethodNameCheck in project sonar-java by SonarSource.

the class GeneratedCodeFilterTest method test.

@Test
public void test() {
    CommentRegularExpressionCheck commentRegularExpressionCheck = new CommentRegularExpressionCheck();
    commentRegularExpressionCheck.regularExpression = ".*alpha.*";
    FilterVerifier.verify("src/test/files/filters/GeneratedCodeFilter.java", new GeneratedCodeFilter(), // activated rules
    commentRegularExpressionCheck, new BadClassNameCheck(), new BadMethodNameCheck(), new BadLocalVariableNameCheck());
}
Also used : BadMethodNameCheck(org.sonar.java.checks.naming.BadMethodNameCheck) CommentRegularExpressionCheck(org.sonar.java.checks.CommentRegularExpressionCheck) BadClassNameCheck(org.sonar.java.checks.naming.BadClassNameCheck) BadLocalVariableNameCheck(org.sonar.java.checks.naming.BadLocalVariableNameCheck) Test(org.junit.Test)

Example 2 with BadMethodNameCheck

use of org.sonar.java.checks.naming.BadMethodNameCheck in project sonar-java by SonarSource.

the class JavaSquidSensorTest method createSonarComponentsMock.

private static SonarComponents createSonarComponentsMock(SensorContextTester contextTester) {
    Configuration settings = new MapSettings().asConfig();
    DefaultFileSystem fs = contextTester.fileSystem();
    JavaTestClasspath javaTestClasspath = new JavaTestClasspath(settings, fs);
    JavaClasspath javaClasspath = new JavaClasspath(settings, fs);
    FileLinesContext fileLinesContext = mock(FileLinesContext.class);
    FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
    when(fileLinesContextFactory.createFor(any(InputFile.class))).thenReturn(fileLinesContext);
    SonarComponents sonarComponents = spy(new SonarComponents(fileLinesContextFactory, fs, javaClasspath, javaTestClasspath, checkFactory));
    sonarComponents.setSensorContext(contextTester);
    BadMethodNameCheck check = new BadMethodNameCheck();
    when(sonarComponents.checkClasses()).thenReturn(new JavaCheck[] { check });
    return sonarComponents;
}
Also used : SonarComponents(org.sonar.java.SonarComponents) JavaClasspath(org.sonar.java.JavaClasspath) BadMethodNameCheck(org.sonar.java.checks.naming.BadMethodNameCheck) Configuration(org.sonar.api.config.Configuration) MapSettings(org.sonar.api.config.internal.MapSettings) FileLinesContextFactory(org.sonar.api.measures.FileLinesContextFactory) JavaTestClasspath(org.sonar.java.JavaTestClasspath) DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) FileLinesContext(org.sonar.api.measures.FileLinesContext) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile)

Aggregations

BadMethodNameCheck (org.sonar.java.checks.naming.BadMethodNameCheck)2 Test (org.junit.Test)1 InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 Configuration (org.sonar.api.config.Configuration)1 MapSettings (org.sonar.api.config.internal.MapSettings)1 FileLinesContext (org.sonar.api.measures.FileLinesContext)1 FileLinesContextFactory (org.sonar.api.measures.FileLinesContextFactory)1 JavaClasspath (org.sonar.java.JavaClasspath)1 JavaTestClasspath (org.sonar.java.JavaTestClasspath)1 SonarComponents (org.sonar.java.SonarComponents)1 CommentRegularExpressionCheck (org.sonar.java.checks.CommentRegularExpressionCheck)1 BadClassNameCheck (org.sonar.java.checks.naming.BadClassNameCheck)1 BadLocalVariableNameCheck (org.sonar.java.checks.naming.BadLocalVariableNameCheck)1