Skip to content

Commit

Permalink
Merge 83c1b3a into fbab1b4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkravin committed Sep 3, 2014
2 parents fbab1b4 + 83c1b3a commit 66a2981
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
20 changes: 20 additions & 0 deletions sevntu-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>sevntu-checks/src/test/resources/com/github/sevntu/checkstyle/checks/coding/InputForbidCertainImportsDefaultPackageWithoutImports.java</source>
<source>sevntu-checks/src/test/resources/com/github/sevntu/checkstyle/checks/coding/InputForbidsCertainImports.java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public void testNormalWork() throws Exception
{
String importRegexp = ".+\\.api\\..+";

checkConfig.addAttribute("packageNameRegexp", ".+\\.old\\..+");
checkConfig.addAttribute("packageNameRegexp", ".+\\.sevntu\\..+");
checkConfig.addAttribute("forbiddenImportsRegexp", importRegexp);
checkConfig.addAttribute("forbiddenImportsExcludesRegexp", "");

String[] expected = {
"3: " + getCheckMessage(MSG_KEY, importRegexp, "com.puppycrawl.tools.checkstyle.api.Check"),
"9: " + getCheckMessage(MSG_KEY, importRegexp, "com.puppycrawl.tools.checkstyle.api.Check"),
"21: " + getCheckMessage(MSG_KEY, importRegexp, "com.smth.tools.checkstyle.api.Smth"),
"3: " + getCheckMessage(MSG_KEY, importRegexp, "com.puppycrawl.tools.checkstyle.api.AutomaticBean"),
"9: " + getCheckMessage(MSG_KEY, importRegexp, "com.puppycrawl.tools.checkstyle.api.AutomaticBean"),
"21: " + getCheckMessage(MSG_KEY, importRegexp, "com.puppycrawl.tools.checkstyle.api.AutomaticBean"),
};

verify(checkConfig, getPath("InputForbidsCertainImports.java"), expected);
Expand All @@ -57,13 +57,11 @@ public void testNormalWorkWithExcludes() throws Exception
{
String importRegexp = ".+\\.api\\..+";

checkConfig.addAttribute("packageNameRegexp", ".+\\.old\\..+");
checkConfig.addAttribute("packageNameRegexp", ".+\\.sevntu\\..+");
checkConfig.addAttribute("forbiddenImportsRegexp", importRegexp);
checkConfig.addAttribute("forbiddenImportsExcludesRegexp", "com.puppycrawl.+");

String[] expected = {
"21: " + getCheckMessage(MSG_KEY, importRegexp, "com.smth.tools.checkstyle.api.Smth"),
};
String[] expected = {};

verify(checkConfig, getPath("InputForbidsCertainImports.java"), expected);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
package coding.rocket.old.generation;
package com.github.sevntu.checkstyle.checks.coding;

import com.puppycrawl.tools.checkstyle.api.Check; // forbidden
import com.puppycrawl.tools.checkstyle.api.AutomaticBean; // forbidden
import java.io.File;
import org.junit.Test;
import File;

import com.puppycrawl.tools.checkstyle.DefaultConfiguration;

import com.puppycrawl.tools.checkstyle.api.Check; // forbidden!
import com.puppycrawl.tools.checkstyle.api.AutomaticBean; // forbidden!

/**
* @author <a href="mailto:Daniil.Yaroslavtsev@gmail.com"> Daniil
* Yaroslavtsev</a>
*/
public class InputForbidsCertainImports extends Check
{
@Override

public int a()
{

AutomaticBean smth = new com.puppycrawl.tools.checkstyle.api.AutomaticBean(); // forbidden!
return 5;
Smth smth = new com.smth.tools.checkstyle.api.Smth(); // forbidden!
}

public int[] getDefaultTokens()
{
return null;
}

}

0 comments on commit 66a2981

Please sign in to comment.