Compare commits

..

No commits in common. "hacked-lambda-indentation" and "master" have entirely different histories.

863 changed files with 5589 additions and 16104 deletions

View File

@ -1,7 +0,0 @@
ATTENTION:
All scripts in this folder expect to be launched from root folder of repository
Example of usage:
export GOAL="all-sevntu-checks" && ./.ci/travis/travis.sh
export TRAVIS_PULL_REQUEST="" && export GOAL="releasenotes-gen" && ./.ci/travis/travis.sh

View File

@ -1,15 +0,0 @@
#!/bin/bash
set -e
# On Travis, after cloe all files are with 644 permission, on local they are 664, so we check only executable bit
CHMOD=$(find -type f -not -path '*/\.git/*' -a -type f -not -name '*.sh' -a \( -type d -not -perm 775 -o -type f -executable \))
if [[ ! -z $CHMOD ]]; then
echo "Expected mode for non '.sh' files is 664.";
echo "Files that violates this rule:"
for NAMEFILE in $CHMOD
do
echo $NAMEFILE;
done
exit 1;
fi

View File

@ -1,179 +0,0 @@
#!/bin/bash
# Attention, there is no "-x" to avoid problems on Travis
set -e
case $1 in
nondex)
# exclude ConfigurationLoaderTest till https://github.com/TestingResearchIllinois/NonDex/issues/112
mvn --fail-never clean nondex:nondex -Dtest='*,!ConfigurationLoaderTest'
cat `grep -RlE 'td class=.x' .nondex/ | cat` < /dev/null > output.txt
RESULT=$(cat output.txt | wc -c)
cat output.txt
echo 'Size of output:'$RESULT
if [[ $RESULT != 0 ]]; then false; fi
;;
assembly-run-all-jar)
mvn clean package -Passembly
CS_POM_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
echo version:$CS_POM_VERSION
java -jar target/checkstyle-$CS_POM_VERSION-all.jar -c /google_checks.xml \
src/it/resources/com/google/checkstyle/test/chapter3filestructure/rule332nolinewrap/InputNoLineWrapGood.java > output.log
if grep -vE '(Starting audit)|(warning)|(Audit done.)' output.log ; then exit 1; fi
if grep 'warning' output.log ; then exit 1; fi
;;
sonarqube)
if [[ $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi
mvn clean package cobertura:cobertura sonar:sonar \
-Dsonar.host.url=https://sonarqube.com \
-Dsonar.login=$SONAR_TOKEN \
-Dcobertura.report.format=xml -Dmaven.test.failure.ignore=true \
-Dcheckstyle.skip=true -Dpmd.skip=true -Dcheckstyle.ant.skip=true
;;
release-dry-run)
if [ $(git log -1 | grep -E "\[maven-release-plugin\] prepare release" | cat | wc -l) -lt 1 ]; then
mvn release:prepare -DdryRun=true --batch-mode -Darguments='-DskipTests -DskipITs \
-Dcobertura.skip=true -Dpmd.skip=true -Dfindbugs.skip=true -Dxml.skip=true \
-Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dgpg.skip=true'
fi
;;
releasenotes-gen)
.ci/travis/xtr_releasenotes-gen.sh
;;
pr-description)
.ci/travis/xtr_pr-description.sh
;;
check-chmod)
.ci/travis/checkchmod.sh
;;
all-sevntu-checks)
xmlstarlet sel --net --template -m .//module -v "@name" -n config/checkstyle_sevntu_checks.xml \
| grep -vE "Checker|TreeWalker|Filter|Holder" | grep -v "^$" \
| sort | uniq | sed "s/Check$//" > file.txt
wget -q http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/allclasses-frame.html -O - | html2text \
| grep -E "Check$" | cut -d " " -f6 \
| sort | uniq | sed "s/Check$//" > web.txt
diff -u web.txt file.txt
;;
no-exception-test-checkstyle-sevntu-checkstyle)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#checkstyle/checkstyle/' projects-for-travis.properties
sed -i.'' 's/#sevntu-checkstyle/sevntu-checkstyle/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
no-exception-test-guava)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#guava/guava/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
no-exception-test-guava-with-google-checks)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#guava/guava/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
sed -i.'' 's/warning/ignore/' src/main/resources/google_checks.xml
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config ../../src/main/resources/google_checks.xml
;;
no-exception-test-hibernate)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#hibernate-orm/hibernate-orm/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
no-exception-test-findbugs)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#findbugs/findbugs/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
no-exception-test-spring-framework)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#spring-framework/spring-framework/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
no-exception-test-hbase)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#Hbase/Hbase/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
no-exception-test-Pmd-elasticsearch-lombok-ast)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#pmd/pmd/' projects-for-travis.properties
sed -i.'' 's/#elasticsearch/elasticsearch/' projects-for-travis.properties
sed -i.'' 's/#lombok-ast/lombok-ast/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
no-exception-test-alot-of-project1)
git clone https://github.com/checkstyle/contribution
cd contribution/checkstyle-tester
sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
sed -i.'' 's/#RxJava/RxJava/' projects-for-travis.properties
sed -i.'' 's/#java-design-patterns/java-design-patterns/' projects-for-travis.properties
sed -i.'' 's/#MaterialDesignLibrary/MaterialDesignLibrary/' projects-for-travis.properties
sed -i.'' 's/#apache-ant/apache-ant/' projects-for-travis.properties
sed -i.'' 's/#apache-jsecurity/apache-jsecurity/' projects-for-travis.properties
sed -i.'' 's/#android-launcher/android-launcher/' projects-for-travis.properties
cd ../../
mvn clean install -Pno-validations
cd contribution/checkstyle-tester
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;
*)
echo "Unexpected argument: $1"
exit 1
;;
esac

View File

@ -1,29 +0,0 @@
#!/bin/bash
# Attention, there is no "-x" to avoid problems on Travis
set -e
if [[ ! $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi
LINK_COMMITS=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST/commits
COMMITS=$(curl -s -H "Authorization: token $READ_ONLY_TOKEN" $LINK_COMMITS | jq '.[0] | .commit.message')
echo 'Messages from github:'${COMMITS:0:60}...
ISSUE_NUMBER=$(echo $COMMITS | sed -e 's/^.*Issue //' | sed -e 's/:.*//')
echo 'Issue number:'$ISSUE_NUMBER && RESULT=0
if [[ $ISSUE_NUMBER =~ ^#[0-9]+$ ]]; then
LINK_PR=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST
LINK_ISSUE=https://api.github.com/repos/checkstyle/checkstyle/issues/${ISSUE_NUMBER:1}
REGEXP=($ISSUE_NUMBER\|https://github.com/checkstyle/checkstyle/issues/${ISSUE_NUMBER:1})
PR_DESC=$(curl -s -H "Authorization: token $READ_ONLY_TOKEN" $LINK_PR | jq '.body' | grep -E $REGEXP | cat )
echo 'PR Description grepped:'${PR_DESC:0:80}
if [[ -z $PR_DESC ]]; then
echo 'Please put a reference of Issue to PR description, this will bind Issue and PR in Github' && RESULT=1;
fi
LABEL_APRV=$(curl -s -H "Authorization: token $READ_ONLY_TOKEN" $LINK_ISSUE | jq '.labels [] | .name' | grep approved | cat | wc -l )
if [[ $LABEL_APRV == 0 ]]; then
echo 'You provide PR to Issue that is not approved yes, please ask admins to approve your issue first' && RESULT=1;
fi
fi
if [[ $RESULT == 0 ]]; then
echo 'PR validation succeed.';
else
echo 'PR validation failed.' && false;
fi

View File

@ -1,50 +0,0 @@
#!/bin/bash
# Attention, there is no "-x" to avoid problem on Travis
set -e
if [[ $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi
git clone https://github.com/checkstyle/contribution
cd contribution/releasenotes-builder
mvn clean compile package
cd ../../
git clone https://github.com/checkstyle/checkstyle
cd checkstyle
LATEST_RELEASE_TAG=$(git describe $(git rev-list --tags --max-count=1))
cd ../
CS_RELEASE_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | sed 's/-SNAPSHOT//' )
echo LATEST_RELEASE_TAG=$LATEST_RELEASE_TAG
echo CS_RELEASE_VERSION=$CS_RELEASE_VERSION
java -jar contribution/releasenotes-builder/target/releasenotes-builder-1.0-all.jar \
-localRepoPath checkstyle -startRef $LATEST_RELEASE_TAG -releaseNumber $CS_RELEASE_VERSION \
-githubAuthToken $READ_ONLY_TOKEN -generateAll -publishXdoc
echo ==============================================
echo
echo "xdoc segment:"
echo ==============================================
cat xdoc.xml
echo ==============================================
echo
echo "twitter post:"
echo ==============================================
cat twitter.txt
echo ==============================================
echo
echo "google plus post:"
echo ==============================================
cat gplus.txt
echo ==============================================
echo
echo "RSS post:"
echo ==============================================
cat rss.txt
echo ==============================================
echo
echo "mailing list post:"
echo ==============================================
cat mailing_list.txt
echo ==============================================
cd checkstyle/src/xdocs
echo
echo "releasenotes.xml after commit:"
head -n 100 releasenotes.xml

View File

@ -1,17 +1,13 @@
/var/tmp $ javac YOUR_FILE.java /var/tmp $ javac YOUR_FILE.java
[[PLACE YOUR OUTPUT HERE]] [[PLACE YOUR OUTPUT HERE]]
/var/tmp $ cat YOUR_FILE.java /var/tmp $ cat YOUR_FILE.java
[[PLACE YOU OUTPUT HERE]] [[PLACE YOU OUTPUT HERE]]
/var/tmp $ cat config.xml /var/tmp $ cat config.xml
[[PLACE YOUR OUTPUT HERE]] [[PLACE YOUR OUTPUT HERE]]
/var/tmp $ java -jar checkstyle-X.XX-all.jar -c config.xml YOUR_FILE.java /var/tmp $ java -jar checkstyle-X.XX-all.jar -c config.xml YOUR_FILE.java
[[PLACE YOUR OUTPUT HERE]] [[PLACE YOUR OUTPUT HERE]]
--------------- ---------------

View File

@ -2,15 +2,8 @@ language: java
sudo: false sudo: false
cache: cache:
apt: true
directories: directories:
- ~/.m2 - ~/.m2
addons:
apt:
packages:
- xsltproc
- xmlstarlet
branches: branches:
only: only:
@ -22,47 +15,33 @@ install:
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
# testing of PR format
- env:
- DESC="test Issue ref in PR description"
- CMD="./.ci/travis/travis.sh pr-description"
# unit tests (oraclejdk8) # unit tests (oraclejdk8)
- jdk: oraclejdk8 - jdk: oraclejdk8
env: env: DESC="tests and deploy" CMD="mvn clean integration-test failsafe:verify" COVERAGE_CMD="" DEPLOY="true"
- DESC="tests and deploy"
- CMD="mvn clean integration-test failsafe:verify" # NonDex (oraclejdk8)
- DEPLOY="true" - jdk: oraclejdk8
env: DESC="NonDex" CMD="mvn clean nondex:nondex" COVERAGE_CMD="" DEPLOY="false"
# checkstyle (oraclejdk8) # checkstyle (oraclejdk8)
- jdk: oraclejdk8 - jdk: oraclejdk8
env: env:
- DESC="checkstyle and sevntu-checkstyle" - DESC="checkstyle and sevntu-checkstyle"
- CMD="mvn clean verify -DskipTests -DskipITs -Dpmd.skip=true -Dfindbugs.skip=true -Dcobertura.skip=true" - CMD="mvn clean verify -DskipTests -DskipITs -Dpmd.skip=true -Dfindbugs.skip=true -Dcobertura.skip=true"
- COVERAGE_CMD=""
# cobertura and codecov (oraclejdk8) # cobertura and codecov (oraclejdk8)
- jdk: oraclejdk8 - jdk: oraclejdk8
env: env:
- DESC="cobertura and codecov" - DESC="cobertura and codecov"
- CMD="mvn clean compile cobertura:check cobertura:cobertura" - CMD="mvn clean compile cobertura:check cobertura:cobertura"
- CMD_AFTER_SUCCESS="bash <(curl -s https://codecov.io/bash)" - COVERAGE_CMD="bash <(curl -s https://codecov.io/bash)"
# findbugs and pmd (oraclejdk8) # findbugs and pmd (oraclejdk8)
- jdk: oraclejdk8 - jdk: oraclejdk8
env: env:
- DESC="findbugs and pmd" - DESC="findbugs and pmd"
- CMD="mvn clean compile pmd:check findbugs:check" - CMD="mvn clean compile pmd:check findbugs:check"
- COVERAGE_CMD=""
# Releasenotes generation - validaton
- jdk: oraclejdk8
env:
- DESC="Releasenotes generation"
- CMD="./.ci/travis/travis.sh releasenotes-gen"
# NonDex (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NonDex"
- CMD="./.ci/travis/travis.sh nondex"
# site (oraclejdk8 as 'site' success is required to be sure that on release time all will be ok, admins will use oracle8 version) # site (oraclejdk8 as 'site' success is required to be sure that on release time all will be ok, admins will use oracle8 version)
# moved to https://codeship.com/projects/124310/configure_tests # moved to https://codeship.com/projects/124310/configure_tests
@ -75,116 +54,289 @@ matrix:
# - CMD=$CMD1$CMD2$CMD3 # - CMD=$CMD1$CMD2$CMD3
# - COVERAGE_CMD="" # - COVERAGE_CMD=""
# unit tests in German locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests de"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=de -Duser.country=DE'"
# unit tests in Spanish locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests es"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=es -Duser.country=ES'"
# unit tests in Finnish locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests fi"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=fi -Duser.country=FI'"
# unit tests in French locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests fr"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=fr -Duser.country=FR'"
# unit tests in Chinese locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests zh"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=zh -Duser.country=CN'"
# unit tests in Japanese locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests ja"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=ja -Duser.country=JP'"
# unit tests in Portuguese locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests pt"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=pt -Duser.country=PT'"
# unit tests in Turkish locale (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="tests tr"
- CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=tr -Duser.country=TR'"
# assembly (oraclejdk8) # assembly (oraclejdk8)
- jdk: oraclejdk8 - jdk: oraclejdk8
env: env:
- DESC="assembly & run '-all' jar" - DESC="assembly & run '-all' jar"
- CMD="./.ci/travis/travis.sh assembly-run-all-jar" - CMD1="mvn clean package -Passembly"
- CMD2=" && CS_POM_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)"
# NoExceptiontest - Guava with google_checks (oraclejdk8) - CMD3=" && echo version:\$CS_POM_VERSION"
- jdk: oraclejdk8 - CMD4=" && java -jar target/checkstyle-\$CS_POM_VERSION-all.jar -c /google_checks.xml"
env: - CMD5=" src/it/resources/com/google/checkstyle/test/chapter3filestructure/rule332nolinewrap/InputNoLineWrapGood.java > output.log"
- DESC="NoExceptionTest - Guava with google_checks" - CMD6=" && if grep -vE '(Starting audit)|(warning)|(Audit done.)' output.log ; then exit 1; fi "
- CMD="./.ci/travis/travis.sh no-exception-test-guava-with-google-checks" - CMD7=" && if grep 'warning' output.log ; then exit 1; fi"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7
# release dry run (oraclejdk8) - COVERAGE_CMD=""
- jdk: oraclejdk8
env:
- DESC="release dry run"
- CMD="./.ci/travis/travis.sh release-dry-run"
# Check the chmod on files.
- env:
- DESC="check permissions on all files"
- CMD="./.ci/travis/travis.sh check-chmod"
# Ensure that all Sevntu check are kused
- jdk: oraclejdk8
env:
- DESC="All sevntu checks should be used"
- CMD="./.ci/travis/travis.sh all-sevntu-checks"
# MacOS verify (till cache is not working, we can not do verify)
- os: osx
env:
- DESC="MacOS verify, site, assembly"
- CMD="export JAVA_HOME=$(/usr/libexec/java_home) && mvn package -Dlinkcheck.skip=true && mvn package -Passembly "
# https://sonarqube.com (oraclejdk8) # https://sonarqube.com (oraclejdk8)
- jdk: oraclejdk8 - jdk: oraclejdk8
env: env:
- DESC="sonarqube.com" - DESC="sonarqube.com"
- CMD="./.ci/travis/travis.sh sonarqube" - CMD1="if [[ $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi "
- CMD2=" && mvn clean package cobertura:cobertura sonar:sonar "
- CMD3=" -Dsonar.host.url=https://sonarqube.com "
- CMD4=" -Dsonar.login=\$SONAR_TOKEN "
- CMD5=" -Dcobertura.report.format=xml -Dmaven.test.failure.ignore=true "
- CMD6=" -Dcheckstyle.skip=true -Dpmd.skip=true -Dcheckstyle.ant.skip=true "
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6
- COVERAGE_CMD=""
script: # NoExceptiontest - Checkstyle, sevntu-checkstyle (oraclejdk8)
- SKIP_FILES=".github|appveyor.yml|circle.yml|distelli-manifest.yml|fast-forward-merge.sh|LICENSE|LICENSE.apache20|README.md|release.sh|RIGHTS.antlr|shippable.yml|wercker.yml" - jdk: oraclejdk8
- SKIP_CI=$(if [[ $(git diff --name-only HEAD HEAD~1 | grep -vE "$SKIP_FILES" | cat | wc -c) > 0 ]]; then echo false; else echo true; fi;) env:
- echo "SKIP_CI="$SKIP_CI - DESC="NoExceptionTest - Checkstyle, sevntu-checkstyle"
- >- - CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester "
if [[ $SKIP_CI == 'false' ]]; - CMD2=" && sed -i.'' 's/^guava/#guava/' projects-for-travis.properties "
then - CMD3=" && sed -i.'' 's/#checkstyle/checkstyle/' projects-for-travis.properties "
eval $CMD; - CMD4=" && sed -i.'' 's/#sevntu-checkstyle/sevntu-checkstyle/' projects-for-travis.properties "
echo "CMD is finished"; - CMD5=" && sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh "
fi - CMD6=" && cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true "
- CMD7=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD8=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD9=" && cd contribution/checkstyle-tester "
- CMD10=" && ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9$CMD10
- COVERAGE_CMD=""
# NoExceptiontest - Guava (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - Guava"
- CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester"
- CMD2=" && sed -i.'' 's/^guava/#guava/' projects-for-travis.properties"
- CMD3=" && sed -i.'' 's/#guava/guava/' projects-for-travis.properties"
- CMD4=" && sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh"
- CMD5=" && cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true"
- CMD6=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD7=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD8=" && cd contribution/checkstyle-tester "
- CMD9=" && ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9
- COVERAGE_CMD=""
# NoExceptiontest - Guava with google_checks (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - Guava with google_checks"
- CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester"
- CMD2=" && sed -i.'' 's/^guava/#guava/' projects-for-travis.properties"
- CMD3=" && sed -i.'' 's/#guava/guava/' projects-for-travis.properties"
- CMD4=" && sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh"
- CMD5=" && cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true"
- CMD6=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD7=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD8=" && sed -i.'' 's/warning/ignore/' src/main/resources/google_checks.xml"
- CMD9=" && cd contribution/checkstyle-tester "
- CMD10=" && ./launch.sh -Dcheckstyle.config.location=../../src/main/resources/google_checks.xml
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9$CMD10
- COVERAGE_CMD=""
# NoExceptionTest - Hibernate ORM (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - Hibernate ORM"
- CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester "
- CMD2="&& sed -i.'' 's/^guava/#guava/' projects-for-travis.properties "
- CMD3="&& sed -i.'' 's/#hibernate-orm/hibernate-orm/' projects-for-travis.properties "
- CMD4="&& sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh "
- CMD5="&& cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true "
- CMD6=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD7=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD8="&& cd contribution/checkstyle-tester "
- CMD9="&& ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9
- COVERAGE_CMD=""
# NoExceptionTest - FindBugs (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - FindBugs"
- CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester "
- CMD2="&& sed -i.'' 's/^guava/#guava/' projects-for-travis.properties "
- CMD3="&& sed -i.'' 's/#findbugs/findbugs/' projects-for-travis.properties "
- CMD4="&& sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh "
- CMD5="&& cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true "
- CMD6=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD7=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD8="&& cd contribution/checkstyle-tester "
- CMD9="&& ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9
- COVERAGE_CMD=""
# NoExceptionTest - Pmd,elasticsearch,lombok-ast (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - Pmd,elasticsearch,lombok-ast"
- CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester "
- CMD2="&& sed -i.'' 's/^guava/#guava/' projects-for-travis.properties "
- CMD3="&& sed -i.'' 's/#pmd/pmd/' projects-for-travis.properties "
- CMD4="&& sed -i.'' 's/#elasticsearch/elasticsearch/' projects-for-travis.properties "
- CMD5="&& sed -i.'' 's/#lombok-ast/lombok-ast/' projects-for-travis.properties "
- CMD6="&& sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh "
- CMD7="&& cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true "
- CMD8=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD9=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD10="&& cd contribution/checkstyle-tester "
- CMD11="&& ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9$CMD10$CMD11
- COVERAGE_CMD=""
# NoExceptionTest - RxJava,java-design-patterns,MaterialDesignLibrary,apache-ant,apache-jsecurity,android-launcher (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - RxJava,java-design-patterns,MaterialDesignLibrary,apache-ant,apache-jsecurity,android-launcher"
- CMD01="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester "
- CMD02="&& sed -i.'' 's/^guava/#guava/' projects-for-travis.properties "
- CMD03="&& sed -i.'' 's/#RxJava/RxJava/' projects-for-travis.properties "
- CMD04="&& sed -i.'' 's/#java-design-patterns/java-design-patterns/' projects-for-travis.properties "
- CMD05="&& sed -i.'' 's/#MaterialDesignLibrary/MaterialDesignLibrary/' projects-for-travis.properties "
- CMD06="&& sed -i.'' 's/#apache-ant/apache-ant/' projects-for-travis.properties "
- CMD07="&& sed -i.'' 's/#apache-jsecurity/apache-jsecurity/' projects-for-travis.properties "
- CMD08="&& sed -i.'' 's/#android-launcher/android-launcher/' projects-for-travis.properties "
- CMD09="&& sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh "
- CMD10="&& cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true "
- CMD11=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD12=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD13="&& cd contribution/checkstyle-tester "
- CMD14="&& ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD01$CMD02$CMD03$CMD04$CMD05$CMD06$CMD07$CMD08$CMD09$CMD10$CMD11$CMD12$CMD13$CMD14
- COVERAGE_CMD=""
# NoExceptionTest - Spring (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - Spring"
- CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester"
- CMD2=" && sed -i.'' 's/^guava/#guava/' projects-for-travis.properties "
- CMD3=" && sed -i.'' 's/#spring-framework/spring-framework/' projects-for-travis.properties "
- CMD4=" && sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh "
- CMD5=" && cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true "
- CMD6=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD7=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD8=" && cd contribution/checkstyle-tester "
- CMD9=" && ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9
- COVERAGE_CMD=""
# NoExceptionTest - Hbase (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="NoExceptionTest - Hbase"
- CMD1="git clone https://github.com/checkstyle/contribution && cd contribution/checkstyle-tester "
- CMD2="&& sed -i.'' 's/^guava/#guava/' projects-for-travis.properties "
- CMD3="&& sed -i.'' 's/#Hbase/Hbase/' projects-for-travis.properties "
- CMD4="&& sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh "
- CMD5="&& cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true "
- CMD6=" -Dpmd.skip=true -Dfindbugs.skip=true "
- CMD7=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"
- CMD8="&& cd contribution/checkstyle-tester "
- CMD9="&& ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
- CMD=$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9
- COVERAGE_CMD=""
# release dry run (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="release dry run"
- CMD1="mvn release:prepare -DdryRun=true --batch-mode -Darguments='-DskipTests -DskipITs "
- CMD2=" -Dcobertura.skip=true -Dpmd.skip=true -Dfindbugs.skip=true -Dxml.skip=true"
- CMD3=" -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dgpg.skip=true'"
- CMD=$CMD1$CMD2$CMD3
- COVERAGE_CMD=""
# unit tests in German locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests de" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=de -Duser.country=DE'" COVERAGE_CMD=""
# unit tests in Spanish locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests es" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=es -Duser.country=ES'" COVERAGE_CMD=""
# unit tests in Finnish locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests fi" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=fi -Duser.country=FI'" COVERAGE_CMD=""
# unit tests in French locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests fr" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=fr -Duser.country=FR'" COVERAGE_CMD=""
# unit tests in Chinese locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests zh" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=zh -Duser.country=CN'" COVERAGE_CMD=""
# unit tests in Japanese locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests ja" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=ja -Duser.country=JP'" COVERAGE_CMD=""
# unit tests in Portuguese locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests pt" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=pt -Duser.country=PT'" COVERAGE_CMD=""
# unit tests in Turkish locale (oraclejdk8)
- jdk: oraclejdk8
env: DESC="tests tr" CMD="mvn clean integration-test failsafe:verify -DargLine='-Duser.language=tr -Duser.country=TR'" COVERAGE_CMD=""
# No java8 support on Travis for MacOS
# Config is disabled till https://github.com/travis-ci/travis-ci/issues/2317
# MacOS verify (till cache is not working, we can not do verify)
#- os: osx
# env:
# - DESC="MacOS verify, site, assembly"
# - CMD="export JAVA_HOME=$(/usr/libexec/java_home) && mvn package -Dlinkcheck.skip=true && mvn package -Passembly "
# - COVERAGE_CMD=""
# Releasenotes generation - validaton
- jdk: oraclejdk8
env:
- DESC="Releasenotes generation"
- CMD0="if [[ $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi "
- CMD1=" && git clone https://github.com/checkstyle/contribution && cd contribution/releasenotes-builder "
- CMD2=" && mvn clean compile package "
- CMD3=" && cd ../../ && git clone https://github.com/checkstyle/checkstyle && cd checkstyle "
- CMD4=" && LATEST_RELEASE_TAG=\$(git describe \$(git rev-list --tags --max-count=1)) && cd ../"
- CMD5=" && CS_RELEASE_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | sed 's/-SNAPSHOT//' ) "
- CMD6=" && echo LATEST_RELEASE_TAG=\$LATEST_RELEASE_TAG && echo CS_RELEASE_VERSION=\$CS_RELEASE_VERSION "
- CMD7=" && java -jar contribution/releasenotes-builder/target/releasenotes-builder-1.0-all.jar "
- CMD8=" -localRepoPath checkstyle -startRef \$LATEST_RELEASE_TAG -releaseNumber \$CS_RELEASE_VERSION -authToken $GITHUB_AUTH_TOKEN -generateAll -publishXdoc"
- CMD9=" && echo && echo =============================================="
- CMD10=" && echo xdoc && echo && cat xdoc.xml"
- CMD11=" && echo twitter post && echo && cat twitter.txt"
- CMD12=" && echo google plus post && echo && cat gplus.txt"
- CMD13=" && echo RSS post && echo && cat rss.txt"
- CMD14=" && echo mailing list post && echo && cat mailing_list.txt"
- CMD15=" && cd checkstyle/src/xdocs && echo releasenotes.xml after commit && echo && head -n 100 releasenotes.xml"
- CMD=$CMD0$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9$CMD10$CMD9$CMD11$CMD9$CMD12$CMD9$CMD13$CMD9$CMD14$CMD9$CMD15
- COVERAGE_CMD=""
# testing of PR format
- env:
- DESC="test Issue ref in PR description"
- CMD_="set -e"
- CMD0=" && if [[ ! $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi "
- CMD1=" && LINK_COMMITS=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST/commits "
- CMD2=" && COMMITS=\$(curl -s -H 'Authorization: token $GITHUB_AUTH_TOKEN' \$LINK_COMMITS | jq '.[0] | .commit.message') "
- CMD3=" && echo 'Messages from github:'\${COMMITS:0:60}... "
- CMD4=" && ISSUE_NUMBER=\$( echo \$COMMITS | sed -e 's/^.*Issue //' | sed -e 's/:.*//') "
- CMD5=" && echo 'Issue number:'\$ISSUE_NUMBER && RESULT=0"
- CMD6=" && if [[ \$ISSUE_NUMBER =~ ^#[0-9]+$ ]]; then "
- CMD7=" LINK_PR=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST "
- CMD8=" && LINK_ISSUE=https://api.github.com/repos/checkstyle/checkstyle/issues/\${ISSUE_NUMBER:1} "
- CMD9=" && REGEXP=(\$ISSUE_NUMBER\|https://github.com/checkstyle/checkstyle/issues/\${ISSUE_NUMBER:1})"
- CMD10=" && PR_DESC=\$(curl -s -H 'Authorization: token $GITHUB_AUTH_TOKEN' \$LINK_PR | jq '.body' | grep -E \$REGEXP | cat ) "
- CMD11=" && echo 'PR Description grepped:'\${PR_DESC:0:80} "
- CMD12=" && if [[ -z \$PR_DESC ]]; then "
- CMD13=" echo 'Please put a reference of Issue to PR description, this will bind Issue and PR in Github' && RESULT=1; "
- CMD14=" fi "
- CMD15=" && LABEL_APRV=\$(curl -s -H 'Authorization: token $GITHUB_AUTH_TOKEN' \$LINK_ISSUE | jq '.labels [] | .name' | grep approved | cat | wc -l ) "
- CMD16=" && if [[ \$LABEL_APRV == 0 ]]; then "
- CMD17=" echo 'You provide PR to Issue that is not approved yes, please ask admins to approve your issue first' && RESULT=1; "
- CMD18=" fi "
- CMD19=" fi "
- CMD20=" && if [[ \$RESULT == 0 ]]; then "
- CMD21=" echo 'PR validation succeed.'; "
- CMD22=" else "
- CMD23=" echo 'PR validation failed.' && false; "
- CMD24=" fi "
- CMD=$CMD_$CMD0$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9$CMD10$CMD11$CMD12$CMD13$CMD14$CMD15
- CMD=$CMD$CMD16$CMD17$CMD18$CMD19$CMD20$CMD21$CMD22$CMD23$CMD24
- COVERAGE_CMD=""
script: eval $CMD
after_success: after_success:
- >- - eval $COVERAGE_CMD
if [[ -n $CMD_AFTER_SUCCESS
&& $SKIP_CI == 'false'
]];
then
eval $CMD_AFTER_SUCCESS;
echo "CMD_AFTER_SUCCESS is finished";
fi
- >- - >-
if [[ $TRAVIS_REPO_SLUG == 'checkstyle/checkstyle' if [[ $TRAVIS_REPO_SLUG == 'checkstyle/checkstyle'
&& $TRAVIS_BRANCH == 'master' && $TRAVIS_BRANCH == 'master'
&& $TRAVIS_PULL_REQUEST == 'false' && $TRAVIS_PULL_REQUEST == 'false'
&& $DEPLOY == 'true' && $DEPLOY == 'true'
&& $SKIP_CI == 'false'
]]; ]];
then then
mvn -s config/deploy-settings.xml -Pno-validations deploy; mvn -s config/deploy-settings.xml deploy \
echo "deploy to maven snapshot repository is finished"; -DskipTests -DskipITs -Dpmd.skip=true -Dfindbugs.skip=true \
-Dcobertura.skip=true -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true ;
fi fi

38
LICENSE
View File

@ -2,13 +2,13 @@
Version 2.1, February 1999 Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc. Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
(This is the first released version of the Lesser GPL. It also counts [This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.) the version number 2.1.]
Preamble Preamble
@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be author's reputation will not be affected by problems that might be
introduced by others. introduced by others.
Finally, software patents pose a constant threat to the existence of Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a effectively restrict the users of a free program by obtaining a
@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The "work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must former contains code derived from the library, whereas the latter must
be combined with the library in order to run. be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does. and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's 1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an you conspicuously and appropriately publish on each copy an
@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy, You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a and you may at your option offer warranty protection in exchange for a
fee. fee.
2. You may modify your copy or copies of the Library or any portion 2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in that version instead if you wish.) Do not make any other change in
these notices. these notices.
Once this change is made in a given copy, it is irreversible for Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy. subsequent copies and derivative works made from that copy.
@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6. distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6, Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself. whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or 6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work work containing portions of the Library, and distribute that work
@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you use both them and the Library together in an executable that you
distribute. distribute.
7. You may place library facilities that are a work based on the 7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined facilities not covered by this License, and distribute such a combined
@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein. restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with You are not responsible for enforcing compliance by third parties with
this License. this License.
11. If, as a consequence of a court judgment or allegation of patent 11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or conditions are imposed on you (whether by court order, agreement or
@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by license version number, you may choose any version ever published by
the Free Software Foundation. the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free 14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these, programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is write to the author to ask for permission. For software which is
@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES. DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest If you develop a new library, and you want it to be of the greatest
@ -470,8 +470,8 @@ safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found. "copyright" line and a pointer to where the full notice is found.
{description} <one line to give the library's name and a brief idea of what it does.>
Copyright (C) {year} {fullname} Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@ -485,8 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
USA
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
@ -495,10 +494,9 @@ school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names: necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random library `Frob' (a library for tweaking knobs) written by James Random Hacker.
Hacker.
{signature of Ty Coon}, 1 April 1990 <signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice Ty Coon, President of Vice
That's all there is to it! That's all there is to it!

View File

@ -4,7 +4,6 @@
[![][codeship img]][codeship] [![][codeship img]][codeship]
[![][circleci img]][circleci] [![][circleci img]][circleci]
[![][wercker img]][wercker] [![][wercker img]][wercker]
[![][shippable img]][shippable]
[![][coverage img]][coverage] [![][coverage img]][coverage]
[![][mavenbadge img]][mavenbadge] [![][mavenbadge img]][mavenbadge]
@ -112,7 +111,3 @@ directory.
[wercker]: https://app.wercker.com/project/bykey/cd383127330ff96f89f1a78e8fd1a557 [wercker]: https://app.wercker.com/project/bykey/cd383127330ff96f89f1a78e8fd1a557
[wercker img]: https://app.wercker.com/status/cd383127330ff96f89f1a78e8fd1a557/s/master [wercker img]: https://app.wercker.com/status/cd383127330ff96f89f1a78e8fd1a557/s/master
[shippable]: https://app.shippable.com/projects/577032be3be4f4faa56adb38
[shippable img]: https://img.shields.io/shippable/577032be3be4f4faa56adb38/master.svg?label=shippable

View File

@ -12,7 +12,7 @@ init:
install: install:
- ps: | - ps: |
Add-Type -AssemblyName System.IO.Compression.FileSystem Add-Type -AssemblyName System.IO.Compression.FileSystem
if (!(Test-Path -Path "C:\maven\apache-maven-3.2.5" )) { if (!(Test-Path -Path "C:\maven" )) {
(new-object System.Net.WebClient).DownloadFile( (new-object System.Net.WebClient).DownloadFile(
'http://www.us.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip', 'http://www.us.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip',
'C:\maven-bin.zip' 'C:\maven-bin.zip'
@ -27,7 +27,7 @@ install:
- cmd: '%CYG_BIN% -qnNdO -R %CYG_ROOT% -s %CYG_MIRROR% -l %CYG_CACHE% -P hg' - cmd: '%CYG_BIN% -qnNdO -R %CYG_ROOT% -s %CYG_MIRROR% -l %CYG_CACHE% -P hg'
cache: cache:
- C:\maven\apache-maven-3.2.5 - C:\maven\
- C:\Users\appveyor\.m2 - C:\Users\appveyor\.m2
- C:\cygwin\var\cache\setup - C:\cygwin\var\cache\setup
@ -64,7 +64,7 @@ environment:
# site, without verify # site, without verify
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0 - JAVA_HOME: C:\Program Files\Java\jdk1.8.0
DESC: "site, without verify" DESC: "site, without verify"
CMD1: "mvn -e -Pno-validations site" CMD1: "mvn -e -Psite-only site"
build_script: build_script:
- ps: > - ps: >

View File

@ -2,49 +2,45 @@ checkout:
post: post:
- git clone https://github.com/checkstyle/contribution - git clone https://github.com/checkstyle/contribution
dependencies: dependencies:
cache_directories:
- groovy-2.4.7
pre:
- if [ ! -d groovy-2.4.7 ]; then wget https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.7.zip && unzip apache-groovy-binary-2.4.7.zip; fi
# we to override as 'mvn dependecy:go-ofline' does not download all dependencies # we to override as 'mvn dependecy:go-ofline' does not download all dependencies
override: override:
- mvn install -Pno-validations - mvn install -Passembly
- eval $TESTER_DEPENDENCIES - eval $TESTER_DEPENDENCIES
machine: machine:
java: java:
version: oraclejdk8 version: oraclejdk8
environment: environment:
CMD1: "cd contribution/checkstyle-tester" CMD1: "cd contribution/checkstyle-tester"
DEP1: " && sed -i'' 's/^guava/#guava/' projects-to-test-on.properties" DEP1: " && sed -i.'' 's/^guava/#guava/' projects-to-test-on.properties"
# we need this to let pass 'mvn site' on no-projects mode to download all dependecies # we need this to let pass 'mvn site' on no-projects mode to download all dependecies
DEP2: " && echo 'class ClassEmpty{}' > src/main/java/EmptyClass.java" DEP2: " && echo 'class ClassEmpty{}' > src/main/java/EmptyClass.java"
DEP3: " && /home/ubuntu/checkstyle/groovy-2.4.7/bin/groovy launch.groovy --listOfProjects projects-to-test-on.properties --config my_check.xml" DEP3: " && ./launch.sh -Dcheckstyle.config.location=my_check.xml"
TESTER_DEPENDENCIES: $CMD1$DEP1$DEP2$DEP3 TESTER_DEPENDENCIES: $CMD1$DEP1$DEP2$DEP3
CMD2: " && sed -i'' 's/^openjdk/#openjdk/' projects-for-circle.properties" CMD2: " && sed -i.'' 's/^openjdk/#openjdk/' projects-for-circle.properties"
CMD3: " && /home/ubuntu/checkstyle/groovy-2.4.7/bin/groovy launch.groovy --listOfProjects projects-for-circle.properties --config checks-nonjavadoc-error.xml" CMD3: " && sed -i.'' s/projects-to-test-on.properties/projects-for-circle.properties/ launch.sh"
OPENJDK7: " && sed -i'' 's/#openjdk7/openjdk7/' projects-for-circle.properties" CMD4: " && ./launch.sh -Dcheckstyle.config.location=checks-nonjavadoc-error.xml"
OPENJDK8: " && sed -i'' 's/#openjdk8/openjdk8/' projects-for-circle.properties" OPENJDK7: " && sed -i.'' 's/#openjdk7/openjdk7/' projects-for-circle.properties"
OPENJDK9: " && sed -i'' 's/#openjdk9/openjdk9/' projects-for-circle.properties" OPENJDK8: " && sed -i.'' 's/#openjdk8/openjdk8/' projects-for-circle.properties"
INFINISPAN: " && sed -i'' 's/#infinispan/infinispan/' projects-for-circle.properties" OPENJDK9: " && sed -i.'' 's/#openjdk9/openjdk9/' projects-for-circle.properties"
PROTONPACK: " && sed -i'' 's/#protonpack/protonpack/' projects-for-circle.properties" INFINISPAN: " && sed -i.'' 's/#infinispan/infinispan/' projects-for-circle.properties"
JOOL: " && sed -i'' 's/#jOOL/jOOL/' projects-for-circle.properties" PROTONPACK: " && sed -i.'' 's/#protonpack/protonpack/' projects-for-circle.properties"
TAPESTRY: " && sed -i'' 's/#tapestry5/tapestry5/' projects-for-circle.properties" JOOL: " && sed -i.'' 's/#jOOL/jOOL/' projects-for-circle.properties"
COMMONS: " && sed -i'' 's/#apache-commons/apache-commons/' projects-for-circle.properties" TAPESTRY: " && sed -i.'' 's/#tapestry5/tapestry5/' projects-for-circle.properties"
LUCENE: " && sed -i'' 's/#lucene-solr/lucene-solr/' projects-for-circle.properties" COMMONS: " && sed -i.'' 's/#apache-commons/apache-commons/' projects-for-circle.properties"
STORM: " && sed -i'' 's/#storm/storm/' projects-for-circle.properties" LUCENE: " && sed -i.'' 's/#lucene-solr/lucene-solr/' projects-for-circle.properties"
HADOOP: " && sed -i'' 's/#hadoop/hadoop/' projects-for-circle.properties" STORM: " && sed -i.'' 's/#storm/storm/' projects-for-circle.properties"
CASSANDRA: " && sed -i'' 's/#cassandra/cassandra/' projects-for-circle.properties" HADOOP: " && sed -i.'' 's/#hadoop/hadoop/' projects-for-circle.properties"
SCOUTER: " && sed -i'' 's/#scouter/scouter/' projects-for-circle.properties" CASSANDRA: " && sed -i.'' 's/#cassandra/cassandra/' projects-for-circle.properties"
GROOVY: " && sed -i'' 's/#groovy/groovy/' projects-for-circle.properties" SCOUTER: " && sed -i.'' 's/#scouter/scouter/' projects-for-circle.properties"
GROOVY: " && sed -i.'' 's/#groovy/groovy/' projects-for-circle.properties"
# Test over openjdk7,8 # Test over openjdk7,8
TEST_1: $CMD1$CMD2$OPENJDK7$OPENJDK8$CMD3 TEST_1: $CMD1$CMD2$OPENJDK7$OPENJDK8$CMD3$CMD4
# Test over infinispan, protonpack, jOOL, lucene-solr, openjdk9 # Test over infinispan, protonpack, jOOL, lucene-solr, openjdk9
TEST_2: $CMD1$CMD2$INFINISPAN$PROTONPACK$JOOL$LUCENE$OPENJDK9$CMD3 TEST_2: $CMD1$CMD2$INFINISPAN$PROTONPACK$JOOL$LUCENE$OPENJDK9$CMD3$CMD4
# Test over tapestry5, storm, cassandra # Test over tapestry5, storm, cassandra
TEST_3: $CMD1$CMD2$TAPESTRY$STORM$CASSANDRA$CMD3 TEST_3: $CMD1$CMD2$TAPESTRY$STORM$CASSANDRA$CMD3$CMD4
# Test over apache-commons, hadoop, scouter, groovy # Test over apache-commons, hadoop, scouter, groovy
TEST_4: $CMD1$CMD2$COMMONS$HADOOP$SCOUTER$GROOVY$CMD3 TEST_4: $CMD1$CMD2$COMMONS$HADOOP$SCOUTER$GROOVY$CMD3$CMD4
test: test:
override: override:
- case $CIRCLE_NODE_INDEX in 0) eval $TEST_1 ;; 1) eval $TEST_2 ;; 2) eval $TEST_3 ;; 3) eval $TEST_4 ;; esac: - case $CIRCLE_NODE_INDEX in 0) eval $TEST_1 ;; 1) eval $TEST_2 ;; 2) eval $TEST_3 ;; 3) eval $TEST_4 ;; esac:

View File

@ -12,6 +12,8 @@
classpath="${mvn.runtime_classpath}" classpath="${mvn.runtime_classpath}"
/> />
<delete file="${mvn.project.build.directory}/cachefile" />
<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/> <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
<property name="check.config" location="config/checkstyle_checks.xml"/> <property name="check.config" location="config/checkstyle_checks.xml"/>

View File

@ -20,6 +20,7 @@
classname="com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask"> classname="com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask">
<classpath refid="run.classpath"/> <classpath refid="run.classpath"/>
</taskdef> </taskdef>
<delete file="${target.dir}/cachefile" />
<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/> <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
<property name="check.config" location="config/checkstyle_checks.xml"/> <property name="check.config" location="config/checkstyle_checks.xml"/>

View File

@ -14,16 +14,9 @@
<metadata name="com.atlas-sw.eclipse" value="I like Sydney"/> <metadata name="com.atlas-sw.eclipse" value="I like Sydney"/>
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<property name="severity" value="error"/> <property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, xml, vm, g, g4"/> <property name="fileExtensions" value="java, properties, xml, g, g4"/>
<!-- BeforeExecutionFileFilters is required for sources that are based on java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$" />
</module>
<!-- Filters --> <!-- Filters -->
<module name="SeverityMatchFilter"> <module name="SeverityMatchFilter">
@ -135,14 +128,8 @@
<!-- Annotations --> <!-- Annotations -->
<module name="AnnotationLocation"> <module name="AnnotationLocation">
<property name="tokens" value="ANNOTATION_DEF"/>
<property name="tokens" value="ANNOTATION_FIELD_DEF"/>
<property name="allowSamelineSingleParameterlessAnnotation" value="false"/> <property name="allowSamelineSingleParameterlessAnnotation" value="false"/>
</module> </module>
<module name="AnnotationLocation">
<property name="tokens" value="PARAMETER_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="AnnotationUseStyle"/> <module name="AnnotationUseStyle"/>
<module name="MissingDeprecated"/> <module name="MissingDeprecated"/>
<module name="MissingOverride"> <module name="MissingOverride">
@ -157,10 +144,6 @@
<property name="allowInSwitchCase" value="true"/> <property name="allowInSwitchCase" value="true"/>
</module> </module>
<module name="EmptyBlock"> <module name="EmptyBlock">
<property name="tokens" value="LITERAL_CATCH"/>
<property name="tokens" value="ARRAY_INIT"/>
<property name="tokens" value="LITERAL_DEFAULT"/>
<property name="tokens" value="LITERAL_CASE"/>
<property name="option" value="text"/> <property name="option" value="text"/>
</module> </module>
<module name="EmptyCatchBlock"/> <module name="EmptyCatchBlock"/>
@ -168,28 +151,17 @@
<property name="maxLineLength" value="100"/> <property name="maxLineLength" value="100"/>
</module> </module>
<module name="NeedBraces"/> <module name="NeedBraces"/>
<module name="NeedBraces">
<property name="tokens" value="LAMBDA"/>
<property name="allowSingleLineStatement" value="true"/>
</module>
<module name="RightCurly"> <module name="RightCurly">
<property name="tokens" value="METHOD_DEF"/>
<property name="tokens" value="CTOR_DEF"/>
<property name="tokens" value="CLASS_DEF"/>
<property name="tokens" value="INSTANCE_INIT"/>
<property name="tokens" value="LITERAL_FOR"/>
<property name="tokens" value="STATIC_INIT"/>
<property name="tokens" value="LITERAL_WHILE"/>
<property name="option" value="alone"/> <property name="option" value="alone"/>
</module> </module>
<module name="RightCurly">
<property name="tokens" value="LITERAL_DO"/>
<property name="option" value="same"/>
</module>
<!-- Class Design --> <!-- Class Design -->
<module name="DesignForExtension"> <module name="DesignForExtension">
<property name="ignoredAnnotations" value="Override, Test, Before, After, BeforeClass, AfterClass"/> <!--
We should postpone DesignForExtension Check enforcement till next major release
as it will seriously brake backward compatibility with existing usage of our library
-->
<property name="severity" value="ignore"/>
</module> </module>
<module name="FinalClass"/> <module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/> <module name="HideUtilityClassConstructor"/>
@ -224,12 +196,7 @@
</module> </module>
<module name="IllegalInstantiation"/> <module name="IllegalInstantiation"/>
<module name="IllegalThrows"/> <module name="IllegalThrows"/>
<module name="IllegalToken"> <module name="IllegalToken"/>
<property name="tokens" value="LABELED_STAT"/>
<property name="tokens" value="LITERAL_NATIVE"/>
<property name="tokens" value="LITERAL_VOLATILE"/>
<property name="tokens" value="LITERAL_ASSERT"/>
</module>
<module name="IllegalTokenText"/> <module name="IllegalTokenText"/>
<module name="IllegalType"/> <module name="IllegalType"/>
<module name="InnerAssignment"/> <module name="InnerAssignment"/>
@ -275,17 +242,16 @@
<module name="AvoidStaticImport"/> <module name="AvoidStaticImport"/>
<module name="CustomImportOrder"> <module name="CustomImportOrder">
<property name="customImportOrderRules" value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"/> <property name="customImportOrderRules" value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"/>
<property name="specialImportsRegExp" value="^org\."/> <property name="specialImportsRegExp" value="org"/>
<property name="sortImportsInGroupAlphabetically" value="true"/> <property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/> <property name="separateLineBetweenGroups" value="true"/>
</module> </module>
<module name="IllegalImport"/> <module name="IllegalImport"/>
<module name="ImportControl"> <module name="ImportControl">
<property name="file" value="${checkstyle.importcontrol.file}"/> <property name="file" value="${checkstyle.importcontrol.file}"/>
<property name="path" value="^.*[\\/]src[\\/]main[\\/].*$"/>
</module> </module>
<module name="ImportOrder"> <module name="ImportOrder">
<property name="groups" value="/^java\./,javax,org"/> <property name="groups" value="/^javax?\./,org"/>
<property name="ordered" value="true"/> <property name="ordered" value="true"/>
<property name="separated" value="true"/> <property name="separated" value="true"/>
<property name="option" value="top"/> <property name="option" value="top"/>
@ -376,7 +342,7 @@
<!-- Naming Conventions --> <!-- Naming Conventions -->
<module name="AbbreviationAsWordInName"> <module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/> <property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="0"/> <property name="allowedAbbreviationLength" value="1"/>
<property name="allowedAbbreviations" value="AST"/> <property name="allowedAbbreviations" value="AST"/>
</module> </module>
<module name="AbstractClassName"/> <module name="AbstractClassName"/>
@ -456,33 +422,7 @@
<property name="tokens" value="DOT"/> <property name="tokens" value="DOT"/>
<property name="allowLineBreaks" value="true"/> <property name="allowLineBreaks" value="true"/>
</module> </module>
<module name="OperatorWrap"> <module name="OperatorWrap"/>
<property name="tokens" value="QUESTION"/>
<property name="tokens" value="COLON"/>
<property name="tokens" value="EQUAL"/>
<property name="tokens" value="NOT_EQUAL"/>
<property name="tokens" value="DIV"/>
<property name="tokens" value="PLUS"/>
<property name="tokens" value="MINUS"/>
<property name="tokens" value="STAR"/>
<property name="tokens" value="MOD"/>
<property name="tokens" value="SR"/>
<property name="tokens" value="BSR"/>
<property name="tokens" value="GE"/>
<property name="tokens" value="GT"/>
<property name="tokens" value="SL"/>
<property name="tokens" value="LE"/>
<property name="tokens" value="LT"/>
<property name="tokens" value="BXOR"/>
<property name="tokens" value="BOR"/>
<property name="tokens" value="LOR"/>
<property name="tokens" value="BAND"/>
<property name="tokens" value="LAND"/>
<property name="tokens" value="TYPE_EXTENSION_AND"/>
<property name="tokens" value="LITERAL_INSTANCEOF"/>
<property name="tokens" value="METHOD_REF"/>
<property name="option" value="nl"/>
</module>
<module name="OperatorWrap"> <module name="OperatorWrap">
<property name="tokens" value="ASSIGN"/> <property name="tokens" value="ASSIGN"/>
<property name="tokens" value="DIV_ASSIGN"/> <property name="tokens" value="DIV_ASSIGN"/>
@ -501,15 +441,10 @@
<module name="ParenPad"/> <module name="ParenPad"/>
<module name="SeparatorWrap"> <module name="SeparatorWrap">
<property name="tokens" value="DOT"/> <property name="tokens" value="DOT"/>
<property name="tokens" value="AT"/>
<property name="option" value="nl"/> <property name="option" value="nl"/>
</module> </module>
<module name="SeparatorWrap"> <module name="SeparatorWrap">
<property name="tokens" value="COMMA"/> <property name="tokens" value="COMMA"/>
<property name="tokens" value="RBRACK"/>
<property name="tokens" value="ARRAY_DECLARATOR"/>
<property name="tokens" value="ELLIPSIS"/>
<property name="tokens" value="SEMI"/>
<property name="option" value="EOL"/> <property name="option" value="EOL"/>
</module> </module>
<module name="SingleSpaceSeparator"> <module name="SingleSpaceSeparator">

View File

@ -7,9 +7,6 @@
<module name="Checker"> <module name="Checker">
<!-- All checks are from https://github.com/sevntu-checkstyle/sevntu.checkstyle project --> <!-- All checks are from https://github.com/sevntu-checkstyle/sevntu.checkstyle project -->
<!-- Hard coded until https://issues.apache.org/jira/browse/MCHECKSTYLE-332 is released. -->
<property name="cacheFile" value="target/cachefile-sevntu"/>
<!-- Filters --> <!-- Filters -->
<module name="SuppressionFilter"> <module name="SuppressionFilter">
<property name="file" value="${project.basedir}/config/sevntu_suppressions.xml"/> <property name="file" value="${project.basedir}/config/sevntu_suppressions.xml"/>
@ -95,6 +92,8 @@
<property name="checkReadObjectMethod" value="true"/> <property name="checkReadObjectMethod" value="true"/>
<property name="matchMethodsByArgCount" value="true"/> <property name="matchMethodsByArgCount" value="true"/>
</module> </module>
<!--commented till https://github.com/sevntu-checkstyle/sevntu.checkstyle/issues/410-->
<!--<module name="AvoidModifiersForTypes"/>-->
<module name="ForbidAnnotation"> <module name="ForbidAnnotation">
<property name="annotationNames" value="Ignore, VisibleForTesting"/> <property name="annotationNames" value="Ignore, VisibleForTesting"/>
<property name="annotationTargets" value="METHOD_DEF"/> <property name="annotationTargets" value="METHOD_DEF"/>
@ -121,10 +120,7 @@
<module name="ForbidCertainImports"> <module name="ForbidCertainImports">
<property name="packageNameRegexp" value=".+\.checkstyle\.api.*|.+\.checkstyle\.utils.*"/> <property name="packageNameRegexp" value=".+\.checkstyle\.api.*|.+\.checkstyle\.utils.*"/>
<property name="forbiddenImportsRegexp" value=".+\.checks\..+"/> <property name="forbiddenImportsRegexp" value=".+\.checks\..+"/>
<!-- AccessModifier is in util package (should be moved to api package) to disallow <property name="forbiddenImportsExcludesRegexp" value=""/>
its usage by API clients till https://github.com/checkstyle/checkstyle/issues/3511-->
<property name="forbiddenImportsExcludesRegexp"
value="^com.puppycrawl.tools.checkstyle.checks.naming.AccessModifier$"/>
</module> </module>
<module name="LineLengthExtended"> <module name="LineLengthExtended">
<property name="max" value="100"/> <property name="max" value="100"/>
@ -178,17 +174,5 @@
<module name="SingleBreakOrContinueCheck"/> <module name="SingleBreakOrContinueCheck"/>
<module name="NumericLiteralNeedsUnderscoreCheck"/> <module name="NumericLiteralNeedsUnderscoreCheck"/>
<module name="UniformEnumConstantNameCheck" /> <module name="UniformEnumConstantNameCheck" />
<module name="ForbidAnnotationElementValueCheck" />
<module name="HideUtilityClassConstructorCheck" />
<module name="AvoidModifiersForTypesCheck">
<property name="forbiddenClassesRegexpProtected" value="Logger"/>
<property name="forbiddenClassesRegexpPublic" value="Logger"/>
<property name="forbiddenClassesRegexpPackagePrivate" value="Logger"/>
</module>
<module name="ConstructorWithoutParamsCheck">
<property name="classNameFormat" value=".*Exception$"/>
<property name="ignoredClassNameFormat" value="UnsupportedOperationException"/>
</module>
<module name="ReturnCountExtendedCheck" />
</module> </module>
</module> </module>

View File

@ -66,7 +66,7 @@
</Or> </Or>
</Match> </Match>
<Match> <Match>
<!-- till https://github.com/checkstyle/checkstyle/issues/3666 --> <!-- till SonarQube update Checkstyle version. Support both getFileName() and getFilename() -->
<and> <and>
<Class name="com.puppycrawl.tools.checkstyle.api.FileContents" /> <Class name="com.puppycrawl.tools.checkstyle.api.FileContents" />
<Method name="~setFile[nN]ame" /> <Method name="~setFile[nN]ame" />
@ -108,14 +108,8 @@
<Match> <Match>
<!-- Temporary disabled. Have to deal with Javadoc nodes as well <!-- Temporary disabled. Have to deal with Javadoc nodes as well
See https://github.com/checkstyle/checkstyle/issues/3432--> See https://github.com/checkstyle/checkstyle/issues/3432-->
<Class name="com.puppycrawl.tools.checkstyle.gui.TreeTable" /> <Class name="com.puppycrawl.tools.checkstyle.gui.JTreeTable" />
<Method name="makeCodeSelection"/> <Method name="makeCodeSelection"/>
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/> <Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
</Match> </Match>
<Match>
<!-- Until https://github.com/checkstyle/checkstyle/issues/3573 -->
<Class name="com.puppycrawl.tools.checkstyle.checks.FileContentsHolder" />
<Method name="beginTree"/>
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
</Match>
</FindBugsFilter> </FindBugsFilter>

View File

@ -1,35 +1,29 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE import-control PUBLIC <!DOCTYPE import-control PUBLIC
"-//Puppy Crawl//DTD Import Control 1.2//EN" "-//Puppy Crawl//DTD Import Control 1.1//EN"
"http://checkstyle.sourceforge.net/dtds/import_control_1_2.dtd"> "http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
<import-control pkg="com.puppycrawl.tools.checkstyle"> <import-control pkg="com.puppycrawl.tools.checkstyle">
<allow pkg="antlr"/> <allow pkg="antlr"/>
<allow pkg="org.antlr.v4.runtime"/>
<allow pkg="com.puppycrawl.tools.checkstyle.api"/> <allow pkg="com.puppycrawl.tools.checkstyle.api"/>
<allow pkg="com.puppycrawl.tools.checkstyle.checks"/> <allow pkg="com.puppycrawl.tools.checkstyle.checks"/>
<allow pkg="java.io"/> <allow pkg="java.io"/>
<allow pkg="java.net"/> <allow pkg="java.net"/>
<allow pkg="java.nio"/>
<allow pkg="java.util"/> <allow pkg="java.util"/>
<allow pkg="javax.xml.parsers"/> <allow pkg="javax.xml.parsers"/>
<allow pkg="org.apache.commons.beanutils"/> <allow pkg="org.apache.commons.beanutils"/>
<allow pkg="org.apache.commons.logging"/> <allow pkg="org.apache.commons.logging"/>
<allow pkg="org.xml.sax"/> <allow pkg="org.xml.sax"/>
<allow pkg="com.puppycrawl.tools.checkstyle"/>
<allow pkg="java.lang.reflect"/>
<!-- The local ones --> <!-- The local ones -->
<allow pkg="java.lang.reflect" local-only="true" />
<allow pkg="java.nio" local-only="true" />
<allow class="java.security.MessageDigest" local-only="true"/> <allow class="java.security.MessageDigest" local-only="true"/>
<allow class="java.security.NoSuchAlgorithmException" local-only="true"/> <allow class="java.security.NoSuchAlgorithmException" local-only="true"/>
<allow class="javax.xml.bind.DatatypeConverter" local-only="true"/> <allow class="javax.xml.bind.DatatypeConverter" local-only="true"/>
<allow pkg="com.puppycrawl.tools.checkstyle.utils" local-only="true"/>
<allow pkg="com.puppycrawl.tools.checkstyle.grammars" local-only="true"/>
<allow pkg="org.apache.commons.cli" local-only="true"/>
<allow pkg="org.antlr.v4.runtime" local-only="true"/>
<allow class="com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.+"
local-only="true" regex="true"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3455 -->
<allow class="com.google.common.base.CaseFormat" local-only="true"/> <allow class="com.google.common.base.CaseFormat" local-only="true"/>
<allow class="com.google.common.io.Closeables" local-only="true"/> <allow class="com.google.common.io.Closeables" local-only="true"/>
<allow class="com.google.common.io.Flushables" local-only="true"/> <allow class="com.google.common.io.Flushables" local-only="true"/>
@ -37,110 +31,107 @@
<allow class="com.google.common.collect.ImmutableCollection" local-only="true"/> <allow class="com.google.common.collect.ImmutableCollection" local-only="true"/>
<allow class="com.google.common.collect.ImmutableList" local-only="true"/> <allow class="com.google.common.collect.ImmutableList" local-only="true"/>
<allow class="com.google.common.collect.ImmutableMap" local-only="true"/> <allow class="com.google.common.collect.ImmutableMap" local-only="true"/>
<allow class="com.google.common.collect.MapDifference" local-only="true"/>
<allow class="com.google.common.collect.Maps" local-only="true"/>
<allow class="com.google.common.collect.Multimap" local-only="true"/> <allow class="com.google.common.collect.Multimap" local-only="true"/>
<allow class="com.google.common.io.ByteStreams" local-only="true"/> <allow pkg="com.puppycrawl.tools.checkstyle.grammars" local-only="true"/>
<allow pkg="org.apache.commons.cli" local-only="true"/>
<subpackage name="utils"> <subpackage name="utils">
<allow pkg="java.lang.reflect" local-only="true" />
<allow pkg="java.nio" local-only="true" />
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3455 -->
<allow class="com.google.common.base.CharMatcher" local-only="true"/> <allow class="com.google.common.base.CharMatcher" local-only="true"/>
<allow class="com.google.common.collect.ImmutableCollection" local-only="true"/>
<allow class="com.google.common.collect.ImmutableMap" local-only="true"/> <allow class="com.google.common.collect.ImmutableMap" local-only="true"/>
</subpackage> </subpackage>
<subpackage name="ant"> <subpackage name="ant">
<allow class="com.google.common.io.Closeables" local-only="true"/>
<allow pkg="org.apache.tools.ant" local-only="true"/> <allow pkg="org.apache.tools.ant" local-only="true"/>
<allow pkg="com.puppycrawl.tools.checkstyle"/>
<disallow pkg="com.puppycrawl.tools.checkstyle.checks"/> <disallow pkg="com.puppycrawl.tools.checkstyle.checks"/>
<disallow pkg="com.puppycrawl.tools.checkstyle.filters"/> <disallow pkg="com.puppycrawl.tools.checkstyle.filters"/>
<disallow pkg="com.puppycrawl.tools.checkstyle.doclets"/> <disallow pkg="com.puppycrawl.tools.checkstyle.doclets"/>
<disallow pkg="com.puppycrawl.tools.checkstyle.gui"/> <disallow pkg="com.puppycrawl.tools.checkstyle.gui"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3455 -->
<allow class="com.google.common.io.Closeables" local-only="true"/>
</subpackage> </subpackage>
<subpackage name="api"> <subpackage name="api">
<allow pkg="com.puppycrawl.tools.checkstyle.grammars"/> <allow pkg="com.puppycrawl.tools.checkstyle.grammars"/>
<allow pkg="java.lang.reflect" local-only="true"/> <allow pkg="java.beans"/>
<allow pkg="java.nio.charset" local-only="true"/> <allow pkg="java.text"/>
<allow class="java.beans.PropertyDescriptor" local-only="true"/>
<allow class="java.text.MessageFormat" local-only="true"/>
<allow class="com.puppycrawl.tools.checkstyle.grammars.CommentListener" <allow class="com.puppycrawl.tools.checkstyle.grammars.CommentListener"
local-only="true"/> local-only="true"/>
<!-- AccessModifier is in util package (should be moved to api package) to disallow <allow class="com.puppycrawl.tools.checkstyle.grammars.GeneratedJavaTokenTypes"
its usage by API clients till https://github.com/checkstyle/checkstyle/issues/3511--> local-only="true"/>
<allow class="com.puppycrawl.tools.checkstyle.checks.naming.AccessModifier" <allow class="com.puppycrawl.tools.checkstyle.Utils"
local-only="true"/> local-only="true"/>
<allow pkg="org.antlr.v4.runtime" local-only="true"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3455 -->
<allow class="com.google.common.io.Closeables" local-only="true"/> <allow class="com.google.common.io.Closeables" local-only="true"/>
<allow class="com.google.common.collect.ImmutableCollection" local-only="true"/> <allow class="com.google.common.collect.ImmutableCollection" local-only="true"/>
<allow class="com.google.common.collect.ImmutableMap" local-only="true"/> <allow class="com.google.common.collect.ImmutableMap" local-only="true"/>
<allow class="com.puppycrawl.tools.checkstyle.Checker" local-only="true"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3817 -->
<allow pkg="com.puppycrawl.tools.checkstyle.utils"/>
</subpackage> </subpackage>
<subpackage name="checks"> <subpackage name="checks">
<allow pkg="java.math"/> <allow pkg="com.puppycrawl.tools.checkstyle.checks"/>
<allow pkg="com.puppycrawl.tools.checkstyle.utils"/> <allow class="com.puppycrawl.tools.checkstyle.Definitions"/>
<allow class="java.nio.charset.StandardCharsets" local-only="true"/>
<allow class="com.puppycrawl.tools.checkstyle.Definitions" local-only="true"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3455 -->
<allow class="com.google.common.io.Closeables" local-only="true"/> <allow class="com.google.common.io.Closeables" local-only="true"/>
<allow class="com.google.common.collect.HashMultiset" local-only="true"/> <allow class="com.google.common.collect.HashMultiset" local-only="true"/>
<allow class="com.google.common.collect.HashMultimap" local-only="true"/> <allow class="com.google.common.collect.HashMultimap" local-only="true"/>
<allow class="com.google.common.collect.ImmutableMap" local-only="true"/>
<allow class="com.google.common.collect.ImmutableMultiset" local-only="true"/> <allow class="com.google.common.collect.ImmutableMultiset" local-only="true"/>
<allow class="com.google.common.collect.Multimap" local-only="true"/>
<allow class="com.google.common.collect.Multiset" local-only="true"/> <allow class="com.google.common.collect.Multiset" local-only="true"/>
<allow class="com.google.common.collect.Multiset.Entry" local-only="true"/> <allow class="com.google.common.collect.Multiset.Entry" local-only="true"/>
<allow class="com.google.common.collect.SetMultimap" local-only="true"/> <allow class="com.google.common.collect.SetMultimap" local-only="true"/>
<allow pkg="java.math"/>
<subpackage name="indentation"> <subpackage name="indentation">
<allow pkg="java.lang.reflect"/> <allow pkg="java.lang.reflect"/>
<allow class="com.google.common.collect.Range" local-only="true"/>
<allow class="com.google.common.collect.RangeMap" local-only="true"/>
</subpackage> </subpackage>
<subpackage name="header"> <subpackage name="header">
<allow class="java.nio.charset.Charset" local-only="true"/> <allow class="java.nio.charset.Charset" local-only="true"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3455 -->
<allow class="com.google.common.io.Closeables" local-only="true"/> <allow class="com.google.common.io.Closeables" local-only="true"/>
</subpackage> </subpackage>
<subpackage name="javadoc"> <subpackage name="javadoc">
<allow pkg="com.puppycrawl.tools.checkstyle.grammars.javadoc"/> <allow pkg="com.puppycrawl.tools.checkstyle.grammars.javadoc"/>
<allow pkg="java.lang.reflect"/> <allow pkg="java.lang.reflect"/>
<allow class="com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser"
local-only="true"/>
<allow class="com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.+"
regex="true" local-only="true"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3455 -->
<allow class="com.google.common.base.CharMatcher" local-only="true"/> <allow class="com.google.common.base.CharMatcher" local-only="true"/>
<allow class="com.google.common.collect.Multiset" local-only="true"/>
</subpackage>
<subpackage name="design">
<allow class="com.google.common.annotations.VisibleForTesting" local-only="true"/>
<allow class="com.google.common.collect.ImmutableMap" local-only="true"/>
</subpackage>
<subpackage name="imports">
<allow class="com.google.common.collect.HashMultimap" local-only="true"/>
</subpackage>
<subpackage name="coding">
<allow class="com.google.common.collect.ImmutableCollection" local-only="true"/>
</subpackage> </subpackage>
</subpackage> </subpackage>
<subpackage name="doclets"> <subpackage name="doclets">
<allow class="java.nio.charset.StandardCharsets" local-only="true"/>
<allow pkg="com.sun.javadoc"/> <allow pkg="com.sun.javadoc"/>
<disallow pkg="com\.puppycrawl\.tools\.checkstyle\.(checks|ant|filters|gui)" regex="true"/> <disallow pkg="com.puppycrawl.tools.checkstyle.(checks|ant|filters|gui)" regex="true"/>
</subpackage> </subpackage>
<subpackage name="filters"> <subpackage name="filters">
<allow class="java.lang.ref.WeakReference" local-only="true"/> <allow pkg="java.lang.ref"/>
<disallow pkg="com\.puppycrawl\.tools\.checkstyle\.checks\.[^.]+" regex="true"/> <allow class="com.google.common.io.Closeables" local-only="true"/>
<allow pkg="com.puppycrawl.tools.checkstyle.utils"/> <allow class="com.google.common.base.CaseFormat" local-only="true"/>
<allow class="com.google.common.collect.ImmutableCollection" local-only="true"/>
<allow class="com.google.common.collect.ImmutableMap" local-only="true"/>
<!-- is not possible till pkg is not a regexp -->
<!-- <disallow pkg="com.puppycrawl.tools.checkstyle.checks.*"/> -->
<disallow pkg="com.puppycrawl.tools.checkstyle.(ant|doclets|gui)" regex="true"/>
</subpackage> </subpackage>
<subpackage name="gui"> <subpackage name="gui">
<allow pkg="java.awt"/> <allow pkg="java.awt"/>
<allow pkg="javax.swing"/> <allow pkg="javax.swing"/>
<allow pkg="com.puppycrawl.tools.checkstyle.utils" local-only="true"/> <disallow pkg="com.puppycrawl.tools.checkstyle.(checks|ant|doclets|filters)" regex="true"/>
<allow class="com.puppycrawl.tools.checkstyle.TreeWalker" local-only="true"/> </subpackage>
<allow class="com.puppycrawl.tools.checkstyle.gui.MainFrameModel.ParseMode"
local-only="true"/> <subpackage name="internal">
<allow class="com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser" local-only="true"/> <allow class="com.google.common.reflect.ClassPath" local-only="true"/>
<allow class="com.google.common.collect.FluentIterable" local-only="true"/>
</subpackage> </subpackage>
</import-control> </import-control>

View File

@ -344,7 +344,7 @@
<inspection_tool class="CloneableImplementsClone" enabled="false" level="ERROR" enabled_by_default="false"> <inspection_tool class="CloneableImplementsClone" enabled="false" level="ERROR" enabled_by_default="false">
<option name="m_ignoreCloneableDueToInheritance" value="false" /> <option name="m_ignoreCloneableDueToInheritance" value="false" />
</inspection_tool> </inspection_tool>
<inspection_tool class="CodeBlock2Expr" enabled="false" level="ERROR" enabled_by_default="true" /> <inspection_tool class="CodeBlock2Expr" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="CoffeeScriptArgumentsOutsideFunction" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="CoffeeScriptArgumentsOutsideFunction" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="CoffeeScriptFunctionSignatures" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="CoffeeScriptFunctionSignatures" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="CoffeeScriptInfiniteLoop" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="CoffeeScriptInfiniteLoop" enabled="true" level="ERROR" enabled_by_default="true" />
@ -1985,10 +1985,6 @@
<option value="MismatchedQueryAndUpdateOfCollection" /> <option value="MismatchedQueryAndUpdateOfCollection" />
<!-- Till https://github.com/checkstyle/checkstyle/issues/3066 --> <!-- Till https://github.com/checkstyle/checkstyle/issues/3066 -->
<option value="ProhibitedExceptionCaught" /> <option value="ProhibitedExceptionCaught" />
<!-- No way to split apart huge if/else branches in test. -->
<option value="IfStatementWithTooManyBranches" />
<!-- we have to catch Exception in Checker and rethrow it -->
<option value="ProhibitedExceptionThrown" />
</list> </list>
</option> </option>
</inspection_tool> </inspection_tool>

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -43,18 +43,11 @@
<property name="violationSuppressXPath" value="//MethodDeclaration[@Name='isNotRelevantSituation' and ../../..[@Image='WhitespaceAroundCheck']] | //MethodDeclaration[@Name='validateCli' and ../../..[@Image='Main']] | //ClassOrInterfaceDeclaration[@Image='JavadocMethodCheck' or @Image='JavadocStyleCheck']"/> <property name="violationSuppressXPath" value="//MethodDeclaration[@Name='isNotRelevantSituation' and ../../..[@Image='WhitespaceAroundCheck']] | //MethodDeclaration[@Name='validateCli' and ../../..[@Image='Main']] | //ClassOrInterfaceDeclaration[@Image='JavadocMethodCheck' or @Image='JavadocStyleCheck']"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/java/codesize.xml/TooManyFields">
<properties>
<!-- Unable to split fields out of class. -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='Checker']"/>
</properties>
</rule>
<rule ref="rulesets/java/codesize.xml/TooManyMethods"> <rule ref="rulesets/java/codesize.xml/TooManyMethods">
<properties> <properties>
<property name="maxmethods" value="20"/> <property name="maxmethods" value="20"/>
<!-- Reducing the number of methods in RequireThisCheck requires making excess hierarchy or duplicating code, or making existing methods too complex. --> <!-- Reducing the number of methods requires making excess hierarchy or duplicating code, or making existing methods too complex. -->
<!-- PackageObjectFactory has many boilerplate methods. --> <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='RequireThisCheck']"/>
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='RequireThisCheck' or @Image='PackageObjectFactory']"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/java/codesize.xml/ExcessiveClassLength"> <rule ref="rulesets/java/codesize.xml/ExcessiveClassLength">
@ -100,6 +93,8 @@
<exclude name="OnlyOneReturn"/> <exclude name="OnlyOneReturn"/>
<!-- opposite to UnnecessaryConstructor --> <!-- opposite to UnnecessaryConstructor -->
<exclude name="AtLeastOneConstructor"/> <exclude name="AtLeastOneConstructor"/>
<!-- deprecated by PMD -->
<exclude name="BooleanInversion"/>
<!-- that rule is too buggy, too much false positives--> <!-- that rule is too buggy, too much false positives-->
<exclude name="DataflowAnomalyAnalysis"/> <exclude name="DataflowAnomalyAnalysis"/>
<!-- turning local variables to fields create design problems and extend scope of variable --> <!-- turning local variables to fields create design problems and extend scope of variable -->
@ -127,7 +122,7 @@
<properties> <properties>
<!-- TreeWalker integrates Checkstyle and antlr and CheckstyleAntTask integrates Checkstyle <!-- TreeWalker integrates Checkstyle and antlr and CheckstyleAntTask integrates Checkstyle
with Ant. Checker collects external resource locations and setup configuration. --> with Ant. Checker collects external resource locations and setup configuration. -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='TreeWalker' or @Image='CheckstyleAntTask' or @Image='Checker' or @Image='Main']"/> <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='TreeWalker' or @Image='CheckstyleAntTask' or @Image='Checker']"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/java/coupling.xml/CouplingBetweenObjects"> <rule ref="rulesets/java/coupling.xml/CouplingBetweenObjects">
@ -153,7 +148,7 @@
<rule ref="rulesets/java/design.xml/ConfusingTernary"> <rule ref="rulesets/java/design.xml/ConfusingTernary">
<properties> <properties>
<!-- false positives on IF_ELSE-IF-ELSE-IF --> <!-- false positives on IF_ELSE-IF-ELSE-IF -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='XMLLogger']//MethodDeclarator[@Image='isReference'] | //ClassOrInterfaceDeclaration[@Image='DetailAST']//MethodDeclarator[@Image='addPreviousSibling'] | //ClassOrInterfaceDeclaration[@Image='AnnotationLocationCheck']//MethodDeclarator[@Image='checkAnnotations'] | //ClassOrInterfaceDeclaration[@Image='ImportControl']//MethodDeclarator[@Image='checkAccess'] | //ClassOrInterfaceDeclaration[@Image='HandlerFactory']//MethodDeclarator[@Image='getHandler']"/> <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='XMLLogger']//MethodDeclarator[@Image='isReference'] | //ClassOrInterfaceDeclaration[@Image='DetailAST']//MethodDeclarator[@Image='addPreviousSibling'] | //ClassOrInterfaceDeclaration[@Image='AnnotationLocationCheck']//MethodDeclarator[@Image='checkAnnotations'] | //ClassOrInterfaceDeclaration[@Image='PkgControl']//MethodDeclarator[@Image='checkAccess'] | //ClassOrInterfaceDeclaration[@Image='HandlerFactory']//MethodDeclarator[@Image='getHandler']"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/java/design.xml/AccessorClassGeneration"> <rule ref="rulesets/java/design.xml/AccessorClassGeneration">
@ -187,17 +182,10 @@
<properties> <properties>
<!-- default is 3 but we try to use single point of exit from method and that require extra IFs --> <!-- default is 3 but we try to use single point of exit from method and that require extra IFs -->
<property name="problemDepth" value="4"/> <property name="problemDepth" value="4"/>
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='ClassResolver']//MethodDeclarator[@Image='resolve']"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/java/empty.xml"/> <rule ref="rulesets/java/empty.xml"/>
<rule ref="rulesets/java/empty.xml/EmptyCatchBlock">
<properties>
<property name="allowCommentedBlocks" value="true"/>
</properties>
</rule>
<rule ref="rulesets/java/finalizers.xml"/> <rule ref="rulesets/java/finalizers.xml"/>
<rule ref="rulesets/java/imports.xml"/> <rule ref="rulesets/java/imports.xml"/>
<rule ref="rulesets/java/javabeans.xml"> <rule ref="rulesets/java/javabeans.xml">
@ -222,6 +210,12 @@
</rule> </rule>
<rule ref="rulesets/java/migrating.xml"/> <rule ref="rulesets/java/migrating.xml"/>
<rule ref="rulesets/java/migrating.xml/JUnit4TestShouldUseTestAnnotation">
<properties>
<!-- False positive of PMD. Non-test methods can be named as 'test' -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='PackageObjectFactory']"/>
</properties>
</rule>
<rule ref="rulesets/java/naming.xml"> <rule ref="rulesets/java/naming.xml">
<!-- we use CheckstyleCustomShortVariable, to control lenght (will be fixed in PMD 5.4) and skip Override methods --> <!-- we use CheckstyleCustomShortVariable, to control lenght (will be fixed in PMD 5.4) and skip Override methods -->
@ -253,7 +247,7 @@
<rule ref="rulesets/java/naming.xml/AbstractNaming"> <rule ref="rulesets/java/naming.xml/AbstractNaming">
<properties> <properties>
<!-- We can not brake compatibility with previous versions --> <!-- We can not brake compatibility with previous versions -->
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='Check' or @Image='AbstractClassNameCheck']"/> <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='Check']"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/java/naming.xml/LongVariable"> <rule ref="rulesets/java/naming.xml/LongVariable">
@ -295,13 +289,6 @@
</rule> </rule>
<rule ref="rulesets/java/strings.xml"/> <rule ref="rulesets/java/strings.xml"/>
<rule ref="rulesets/java/strings.xml/AvoidDuplicateLiterals">
<properties>
<!-- Annotations like '@SuppressWarnings' don't need to be checked, it is better to keep their strings
connected to the annotation instead of separating. -->
<property name="skipAnnotations" value="true"/>
</properties>
</rule>
<rule ref="rulesets/java/sunsecure.xml/MethodReturnsInternalArray"> <rule ref="rulesets/java/sunsecure.xml/MethodReturnsInternalArray">
<properties> <properties>
<!--It's not important when array is empty--> <!--It's not important when array is empty-->

View File

@ -28,21 +28,24 @@
files="AbstractCheckTest.java|AbstractClassNameCheckTest.java|AbstractTypeAwareCheckTest.java|AbstractJavadocCheckTest.java|AbstractViolationReporterTest.java"/> files="AbstractCheckTest.java|AbstractClassNameCheckTest.java|AbstractTypeAwareCheckTest.java|AbstractJavadocCheckTest.java|AbstractViolationReporterTest.java"/>
<!-- Tone down the checking for test code --> <!-- Tone down the checking for test code -->
<suppress checks="CyclomaticComplexity" files="[\\/]XdocsPagesTest\.java"/> <suppress checks="CyclomaticComplexity" files="[\\/]XDocsPagesTest\.java"/>
<suppress checks="IllegalCatch" files="[\\/]internal[\\/]\w+Util\.java"/> <suppress checks="IllegalCatch" files="[\\/]internal[\\/]\w+Util\.java"/>
<suppress checks="EmptyBlock" files=".*[\\/]src[\\/]test[\\/]"/> <suppress checks="EmptyBlock" files=".*[\\/]src[\\/]test[\\/]"/>
<suppress checks="ImportControl" files=".*[\\/]src[\\/](test|it)[\\/]"/> <suppress checks="ImportControl" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="Javadoc" files=".*[\\/]src[\\/](test|it)[\\/]"/> <suppress checks="Javadoc" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="MagicNumber" files=".*[\\/]src[\\/](test|it)[\\/]"/> <suppress checks="MagicNumber" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="AvoidStaticImport" files=".*[\\/]src[\\/](test|it)[\\/]"/> <suppress checks="AvoidStaticImport" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="MethodCount" files="[\\/]ImportOrderCheckTest.java$"/>
<suppress checks="MethodCount" files="[\\/]IndentationCheckTest.java$"/>
<suppress checks="ClassDataAbstractionCoupling" files="[\\/]IndentationCheckTest.java$"/> <suppress checks="ClassDataAbstractionCoupling" files="[\\/]IndentationCheckTest.java$"/>
<suppress checks="MethodCount" files="[\\/]JavadocMethodCheckTest.java$"/>
<suppress checks="MethodCount" files="[\\/]MainTest.java$"/>
<suppress checks="EqualsAvoidNull" files="[\\/]Int.*FilterTest.java$"/> <suppress checks="EqualsAvoidNull" files="[\\/]Int.*FilterTest.java$"/>
<suppress checks="VisibilityModifier" files="[\\/]BaseCheckTestSupport.java$"/> <suppress checks="VisibilityModifier" files="[\\/]BaseCheckTestSupport.java$"/>
<suppress checks="WriteTag" files=".*[\\/]src[\\/](test|it)[\\/]"/> <suppress checks="WriteTag" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<suppress checks="MethodCount" files=".*[\\/]src[\\/](test|it)[\\/]"/>
<!--The Check generates too many violations, fixing them will make code unmanageable.--> <!--The Check generates too many violations, fixing them will make code unmanageable.-->
<suppress checks="MagicNumber" files="(ParseTreeTablePresentation|MainFrame)\.java"/> <suppress checks="MagicNumber" files="(ParseTreeTablePModel|MainFrame)\.java"/>
<!-- Methods that build fake AST are very long--> <!-- Methods that build fake AST are very long-->
<suppress checks="MethodLength" files="src[\\/]test[\\/]java[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]grammars[\\/]comments[\\/]CommentsTest\.java"/> <suppress checks="MethodLength" files="src[\\/]test[\\/]java[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]grammars[\\/]comments[\\/]CommentsTest\.java"/>
@ -68,18 +71,15 @@
<suppress checks="MethodCount" files="[\\/]CommentsIndentationCheck.java$"/> <suppress checks="MethodCount" files="[\\/]CommentsIndentationCheck.java$"/>
<!--VisibilityModifierCheck has 7 options which require 7 additional methods (setters)--> <!--VisibilityModifierCheck has 7 options which require 7 additional methods (setters)-->
<suppress checks="MethodCount" files="[\\/]VisibilityModifierCheck.java$"/> <suppress checks="MethodCount" files="[\\/]VisibilityModifierCheck.java$"/>
<!--RequireThisCheck has a hierarchy of nested classes which contains a lot of methods. -->
<suppress checks="MethodCount" files="[\\/]RequireThisCheck.java$"/>
<!-- we need that set of converters --> <!-- we need that set of converters -->
<suppress checks="ClassDataAbstractionCoupling" files="AutomaticBean\.java"/> <suppress checks="ClassDataAbstractionCoupling" files="AutomaticBean\.java"/>
<!-- they are aggregators of logic, usage a several of classes are ok --> <!-- they are aggregators of logic, usage a several of classes are ok -->
<suppress checks="ClassDataAbstractionCoupling" files="(Checker|TreeWalker|Main|CheckstyleAntTask|JavadocDetailNodeParser)\.java"/> <suppress checks="ClassDataAbstractionCoupling" files="(Checker|TreeWalker|Main|CheckstyleAntTask|JavadocDetailNodeParser)\.java"/>
<suppress checks="ClassDataAbstractionCoupling" files="(CheckerTest|TreeWalkerTest|BaseCheckTestSupport|XdocsPagesTest|CheckstyleAntTaskTest)\.java"/> <suppress checks="ClassDataAbstractionCoupling" files="(CheckerTest|TreeWalkerTest|BaseCheckTestSupport|XDocsPagesTest|CheckstyleAntTaskTest)\.java"/>
<suppress checks="ClassDataAbstractionCoupling" files="PropertyCacheFile\.java"/> <suppress checks="ClassDataAbstractionCoupling" files="PropertyCacheFile\.java"/>
<suppress checks="ClassFanOutComplexity" files="[\\/]Main\.java"/>
<!-- a lot of GUI elements is OK --> <!-- a lot of GUI elements is OK -->
<suppress checks="ClassDataAbstractionCoupling" files="(TreeTable|MainFrame)\.java"/> <suppress checks="ClassDataAbstractionCoupling" files="(JTreeTable|MainFrame)\.java"/>
<!-- Should be fixed after moving https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/master/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/ReturnCountExtendedCheck.java into the main repo --> <!-- Should be fixed after moving https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/master/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/ReturnCountExtendedCheck.java into the main repo -->
<suppress checks="ReturnCount" files="(ClassResolver|ConfigurationLoader|IndentationCheckTest)\.java"/> <suppress checks="ReturnCount" files="(ClassResolver|ConfigurationLoader|IndentationCheckTest)\.java"/>

View File

@ -6,7 +6,7 @@ checkstyle/checkstyle:
- sed -i.'' 's/^guava/#guava/' projects-for-travis.properties - sed -i.'' 's/^guava/#guava/' projects-for-travis.properties
- sed -i.'' 's/#spring-framework/spring-framework/' projects-for-travis.properties - sed -i.'' 's/#spring-framework/spring-framework/' projects-for-travis.properties
- sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh - sed -i.'' 's/projects-to-test-on.properties/projects-for-travis.properties/' launch.sh
- cd ../../ && mvn clean install -Pno-validations - cd ../../ && mvn clean install -DskipTests -DskipITs -Dcobertura.skip=true -Dpmd.skip=true -Dfindbugs.skip=true -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true
- cd contribution/checkstyle-tester - cd contribution/checkstyle-tester
- ./launch.sh -Dcheckstyle.config.location=checks-only-javadoc-error.xml - ./launch.sh -Dcheckstyle.config.location=checks-only-javadoc-error.xml
- if grep "Got an exception" target/site/checkstyle.html; then - if grep "Got an exception" target/site/checkstyle.html; then

909
pom.xml

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,6 @@ mv htdocs/new-site/ .
mv htdocs htdocs-$PREV_RELEASE mv htdocs htdocs-$PREV_RELEASE
mv new-site htdocs mv new-site htdocs
ln -s /home/project-web/checkstyle/reports htdocs/reports ln -s /home/project-web/checkstyle/reports htdocs/reports
ln -s /home/project-web/checkstyle/dtds htdocs/dtds
#Archiving #Archiving
tar cfz htdocs-$PREV_RELEASE.tar.gz htdocs-$PREV_RELEASE/ tar cfz htdocs-$PREV_RELEASE.tar.gz htdocs-$PREV_RELEASE/

View File

@ -1,34 +0,0 @@
language: java
jdk:
- oraclejdk8
env:
matrix:
- PROFILE="-Ppitest-checks-blocks,no-validations"
- PROFILE="-Ppitest-checks-coding,no-validations"
- PROFILE="-Ppitest-checks-design,no-validations"
- PROFILE="-Ppitest-checks-header,no-validations"
- PROFILE="-Ppitest-checks-imports,no-validations"
- PROFILE="-Ppitest-checks-indentation,no-validations"
- PROFILE="-Ppitest-checks-javadoc,no-validations"
- PROFILE="-Ppitest-checks-metrics,no-validations"
- PROFILE="-Ppitest-checks-modifier,no-validations"
- PROFILE="-Ppitest-checks-naming,no-validations"
- PROFILE="-Ppitest-checks-regexp,no-validations"
- PROFILE="-Ppitest-checks-sizes,no-validations"
- PROFILE="-Ppitest-checks-whitespace,no-validations"
build:
cache: true
cache_dir_list:
- /root/.m2
ci:
# we skip PRs and commits that are not for Issues, as pitest is too time consuming
- >-
if [ $(git log -1 | grep -E "Issue \#[0-9]+\:" | cat | wc -l) -gt 0 ];
then
mvn $PROFILE clean verify org.pitest:pitest-maven:mutationCoverage;
fi

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -61,13 +61,6 @@ public class BaseCheckTestSupport {
protected final ByteArrayOutputStream stream = new ByteArrayOutputStream(); protected final ByteArrayOutputStream stream = new ByteArrayOutputStream();
/**
* Returns {@link Configuration} based on Google's checks xml-configuration (google_checks.xml).
* This implementation uses {@link ConfigurationLoader} in order to load configuration
* from xml-file.
* @return {@link Configuration} based on Google's checks xml-configuration (google_checks.xml).
* @throws CheckstyleException if exception occurs during configuration loading.
*/
protected static Configuration getConfiguration() throws CheckstyleException { protected static Configuration getConfiguration() throws CheckstyleException {
if (configuration == null) { if (configuration == null) {
configuration = ConfigurationLoader.loadConfiguration(XML_NAME, new PropertiesExpander( configuration = ConfigurationLoader.loadConfiguration(XML_NAME, new PropertiesExpander(
@ -77,21 +70,10 @@ public class BaseCheckTestSupport {
return configuration; return configuration;
} }
/** protected static DefaultConfiguration createCheckConfig(Class<?> clazz) {
* Creates {@link DefaultConfiguration} instance for the given check class.
* @param clazz check class.
* @return {@link DefaultConfiguration} instance.
*/
private static DefaultConfiguration createCheckConfig(Class<?> clazz) {
return new DefaultConfiguration(clazz.getName()); return new DefaultConfiguration(clazz.getName());
} }
/**
* Creates {@link Checker} instance based on specified {@link Configuration}.
* @param checkConfig {@link Configuration} instance.
* @return {@link Checker} instance.
* @throws CheckstyleException if an exception occurs during checker configuration.
*/
protected Checker createChecker(Configuration checkConfig) protected Checker createChecker(Configuration checkConfig)
throws Exception { throws Exception {
final DefaultConfiguration dc = createCheckerConfig(checkConfig); final DefaultConfiguration dc = createCheckerConfig(checkConfig);
@ -107,12 +89,6 @@ public class BaseCheckTestSupport {
return checker; return checker;
} }
/**
* Creates {@link DefaultConfiguration} or the {@link Checker}.
* based on the given {@link Configuration}.
* @param config {@link Configuration} instance.
* @return {@link DefaultConfiguration} for the {@link Checker}.
*/
protected DefaultConfiguration createCheckerConfig(Configuration config) { protected DefaultConfiguration createCheckerConfig(Configuration config) {
final DefaultConfiguration dc = final DefaultConfiguration dc =
new DefaultConfiguration("configuration"); new DefaultConfiguration("configuration");
@ -124,32 +100,11 @@ public class BaseCheckTestSupport {
return dc; return dc;
} }
/**
* Returns canonical path for the file with the given file name.
* The path is formed based on the specific root location.
* This implementation uses 'src/it/resources/com/google/checkstyle/test/' as a root location.
* @param fileName file name.
* @return canonical path for the the file with the given file name.
* @throws IOException if I/O exception occurs while forming the path.
*/
protected String getPath(String fileName) throws IOException { protected String getPath(String fileName) throws IOException {
return new File("src/it/resources/com/google/checkstyle/test/" + fileName) return new File("src/it/resources/com/google/checkstyle/test/" + fileName)
.getCanonicalPath(); .getCanonicalPath();
} }
/**
* Performs verification of the file with given file name. Uses specified configuration.
* Expected messages are represented by the array of strings, warning line numbers are
* represented by the array of integers.
* This implementation uses overloaded
* {@link BaseCheckTestSupport#verify(Checker, File[], String, String[], Integer...)} method
* inside.
* @param config configuration.
* @param fileName file name to verify.
* @param expected an array of expected messages.
* @param warnsExpected an array of expected warning numbers.
* @throws Exception if exception occurs during verification process.
*/
protected void verify(Configuration config, String fileName, String[] expected, protected void verify(Configuration config, String fileName, String[] expected,
Integer... warnsExpected) throws Exception { Integer... warnsExpected) throws Exception {
verify(createChecker(config), verify(createChecker(config),
@ -157,15 +112,6 @@ public class BaseCheckTestSupport {
fileName, expected, warnsExpected); fileName, expected, warnsExpected);
} }
/**
* Performs verification of files. Uses provided {@link Checker} instance.
* @param checker {@link Checker} instance.
* @param processedFiles files to process.
* @param messageFileName message file name.
* @param expected an array of expected messages.
* @param warnsExpected an array of expected warning line numbers.
* @throws Exception if exception occurs during verification process.
*/
protected void verify(Checker checker, protected void verify(Checker checker,
File[] processedFiles, File[] processedFiles,
String messageFileName, String messageFileName,
@ -246,73 +192,20 @@ public class BaseCheckTestSupport {
return null; return null;
} }
/**
* Returns {@link Configuration} instance for the given check name.
* This implementation uses {@link BaseCheckTestSupport#getConfiguration()} method inside.
* @param checkName check name.
* @return {@link Configuration} instance for the given check name.
* @throws CheckstyleException if exception occurs during configuration loading.
*/
protected static Configuration getCheckConfig(String checkName) throws CheckstyleException { protected static Configuration getCheckConfig(String checkName) throws CheckstyleException {
final Configuration result; Configuration result = null;
final List<Configuration> configs = getCheckConfigs(checkName);
if (configs.size() == 1) {
result = configs.get(0);
}
else {
throw new IllegalStateException("multiple instances of the same Check are detected");
}
return result;
}
/**
* Returns {@link Configuration} instance for the given check name.
* This implementation uses {@link BaseCheckTestSupport#getConfiguration()} method inside.
* @param checkName check name.
* @return {@link Configuration} instance for the given check name.
* @throws CheckstyleException if exception occurs during configuration loading.
*/
protected static Configuration getCheckConfig(String checkName, String checkId)
throws CheckstyleException {
final Configuration result;
final List<Configuration> configs = getCheckConfigs(checkName);
if (configs.size() == 1) {
result = configs.get(0);
}
else {
result = configs.stream().filter(conf -> {
try {
return conf.getAttribute("id").equals(checkId);
}
catch (CheckstyleException ex) {
throw new IllegalStateException("problem to get ID attribute from " + conf, ex);
}
})
.findFirst().orElseGet(null);
}
return result;
}
/**
* Returns a list of all {@link Configuration} instances for the given check name.
* This implementation uses {@link BaseCheckTestSupport#getConfiguration()} method inside.
* @param checkName check name.
* @return {@link Configuration} instance for the given check name.
* @throws CheckstyleException if exception occurs during configuration loading.
*/
protected static List<Configuration> getCheckConfigs(String checkName)
throws CheckstyleException {
final List<Configuration> result = new ArrayList<>();
for (Configuration currentConfig : getConfiguration().getChildren()) { for (Configuration currentConfig : getConfiguration().getChildren()) {
if ("TreeWalker".equals(currentConfig.getName())) { if ("TreeWalker".equals(currentConfig.getName())) {
for (Configuration checkConfig : currentConfig.getChildren()) { for (Configuration checkConfig : currentConfig.getChildren()) {
if (checkName.equals(checkConfig.getName())) { if (checkName.equals(checkConfig.getName())) {
result.add(checkConfig); result = checkConfig;
break;
} }
} }
} }
else if (checkName.equals(currentConfig.getName())) { else if (checkName.equals(currentConfig.getName())) {
result.add(currentConfig); result = currentConfig;
break;
} }
} }
return result; return result;
@ -326,13 +219,6 @@ public class BaseCheckTestSupport {
return path; return path;
} }
/**
* Returns an array of integers which represents the warning line numbers in the file
* with the given file name.
* @param fileName file name.
* @return an array of integers which represents the warning line numbers.
* @throws IOException if I/O exception occurs while reading the file.
*/
protected Integer[] getLinesWithWarn(String fileName) throws IOException { protected Integer[] getLinesWithWarn(String fileName) throws IOException {
final List<Integer> result = new ArrayList<>(); final List<Integer> result = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new InputStreamReader( try (BufferedReader br = new BufferedReader(new InputStreamReader(

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -48,6 +48,7 @@ public class FileTabCharacterTest extends BaseCheckTestSupport {
@Test @Test
public void fileTabTest() throws Exception { public void fileTabTest() throws Exception {
final DefaultConfiguration checkConfig = createConfig(true);
final String[] expected = { final String[] expected = {
"8:25: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"), "8:25: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"),
"51:5: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"), "51:5: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"),
@ -60,10 +61,18 @@ public class FileTabCharacterTest extends BaseCheckTestSupport {
"134:3: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"), "134:3: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"),
}; };
final Configuration checkConfig = getCheckConfig("FileTabCharacter");
final String filePath = getPath("InputFileTabCharacter.java"); final String filePath = getPath("InputFileTabCharacter.java");
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }
/**
* Creates a configuration that is functionally close to that in the docs.
*/
private static DefaultConfiguration createConfig(boolean verbose) {
final DefaultConfiguration checkConfig =
createCheckConfig(FileTabCharacterCheck.class);
checkConfig.addAttribute("eachLine", Boolean.toString(verbose));
return checkConfig;
}
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -37,70 +37,74 @@ public class IllegalTokenTextTest extends BaseCheckTestSupport {
@Test @Test
public void illegalTokensTest() throws Exception { public void illegalTokensTest() throws Exception {
final String message = "Consider using special escape sequence instead of octal value or "
+ "Unicode escaped value.";
final String[] expected = { final String[] expected = {
"18:27: " + message, "17:27: Avoid using corresponding octal or Unicode escape.",
"19:27: " + message, "18:27: Avoid using corresponding octal or Unicode escape.",
"22:25: " + message, "19:27: Avoid using corresponding octal or Unicode escape.",
"23:25: " + message, "22:25: Avoid using corresponding octal or Unicode escape.",
"25:16: " + message, "23:25: Avoid using corresponding octal or Unicode escape.",
"43:21: " + message, "25:16: Avoid using corresponding octal or Unicode escape.",
"44:21: " + message, "42:21: Avoid using corresponding octal or Unicode escape.",
"45:21: " + message, "43:21: Avoid using corresponding octal or Unicode escape.",
"46:21: " + message, "44:21: Avoid using corresponding octal or Unicode escape.",
"47:21: " + message, "45:21: Avoid using corresponding octal or Unicode escape.",
"48:21: " + message, "46:21: Avoid using corresponding octal or Unicode escape.",
"49:21: " + message, "47:21: Avoid using corresponding octal or Unicode escape.",
"54:21: " + message, "48:21: Avoid using corresponding octal or Unicode escape.",
"55:21: " + message, "49:21: Avoid using corresponding octal or Unicode escape.",
"56:21: " + message, "54:21: Avoid using corresponding octal or Unicode escape.",
"57:21: " + message, "55:21: Avoid using corresponding octal or Unicode escape.",
"58:21: " + message, "56:21: Avoid using corresponding octal or Unicode escape.",
"59:21: " + message, "57:21: Avoid using corresponding octal or Unicode escape.",
"60:21: " + message, "58:21: Avoid using corresponding octal or Unicode escape.",
"61:21: " + message, "59:21: Avoid using corresponding octal or Unicode escape.",
"69:31: " + message, "60:21: Avoid using corresponding octal or Unicode escape.",
"70:31: " + message, "61:21: Avoid using corresponding octal or Unicode escape.",
"73:29: " + message, "68:31: Avoid using corresponding octal or Unicode escape.",
"74:29: " + message, "69:31: Avoid using corresponding octal or Unicode escape.",
"76:20: " + message, "70:31: Avoid using corresponding octal or Unicode escape.",
"94:25: " + message, "73:29: Avoid using corresponding octal or Unicode escape.",
"95:25: " + message, "74:29: Avoid using corresponding octal or Unicode escape.",
"96:25: " + message, "76:20: Avoid using corresponding octal or Unicode escape.",
"97:25: " + message, "93:25: Avoid using corresponding octal or Unicode escape.",
"98:25: " + message, "94:25: Avoid using corresponding octal or Unicode escape.",
"99:25: " + message, "95:25: Avoid using corresponding octal or Unicode escape.",
"100:25: " + message, "96:25: Avoid using corresponding octal or Unicode escape.",
"105:25: " + message, "97:25: Avoid using corresponding octal or Unicode escape.",
"106:25: " + message, "98:25: Avoid using corresponding octal or Unicode escape.",
"107:25: " + message, "99:25: Avoid using corresponding octal or Unicode escape.",
"108:25: " + message, "100:25: Avoid using corresponding octal or Unicode escape.",
"109:25: " + message, "105:25: Avoid using corresponding octal or Unicode escape.",
"110:25: " + message, "106:25: Avoid using corresponding octal or Unicode escape.",
"111:25: " + message, "107:25: Avoid using corresponding octal or Unicode escape.",
"112:25: " + message, "108:25: Avoid using corresponding octal or Unicode escape.",
"119:35: " + message, "109:25: Avoid using corresponding octal or Unicode escape.",
"120:35: " + message, "110:25: Avoid using corresponding octal or Unicode escape.",
"123:33: " + message, "111:25: Avoid using corresponding octal or Unicode escape.",
"124:33: " + message, "112:25: Avoid using corresponding octal or Unicode escape.",
"126:24: " + message, "118:35: Avoid using corresponding octal or Unicode escape.",
"144:29: " + message, "119:35: Avoid using corresponding octal or Unicode escape.",
"145:29: " + message, "120:35: Avoid using corresponding octal or Unicode escape.",
"146:29: " + message, "123:33: Avoid using corresponding octal or Unicode escape.",
"147:29: " + message, "124:33: Avoid using corresponding octal or Unicode escape.",
"148:29: " + message, "126:24: Avoid using corresponding octal or Unicode escape.",
"149:29: " + message, "143:29: Avoid using corresponding octal or Unicode escape.",
"150:29: " + message, "144:29: Avoid using corresponding octal or Unicode escape.",
"155:29: " + message, "145:29: Avoid using corresponding octal or Unicode escape.",
"156:29: " + message, "146:29: Avoid using corresponding octal or Unicode escape.",
"157:29: " + message, "147:29: Avoid using corresponding octal or Unicode escape.",
"158:29: " + message, "148:29: Avoid using corresponding octal or Unicode escape.",
"159:29: " + message, "149:29: Avoid using corresponding octal or Unicode escape.",
"160:29: " + message, "150:29: Avoid using corresponding octal or Unicode escape.",
"161:29: " + message, "155:29: Avoid using corresponding octal or Unicode escape.",
"162:29: " + message, "156:29: Avoid using corresponding octal or Unicode escape.",
"157:29: Avoid using corresponding octal or Unicode escape.",
"158:29: Avoid using corresponding octal or Unicode escape.",
"159:29: Avoid using corresponding octal or Unicode escape.",
"160:29: Avoid using corresponding octal or Unicode escape.",
"161:29: Avoid using corresponding octal or Unicode escape.",
"162:29: Avoid using corresponding octal or Unicode escape.",
}; };
final Configuration checkConfig = getCheckConfig("IllegalTokenText"); final Configuration checkConfig = getCheckConfig("IllegalTokenText");

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -31,13 +31,13 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
public class CustomImportOrderTest extends BaseCheckTestSupport { public class CustomImportOrderTest extends BaseCheckTestSupport {
/** Shortcuts to make code more compact. */ private static final String MSG_SEPARATOR = "custom.import.order.line.separator";
private static final String MSG_LINE_SEPARATOR = CustomImportOrderCheck.MSG_LINE_SEPARATOR; private static final String MSG_LEX = "custom.import.order.lex";
private static final String MSG_LEX = CustomImportOrderCheck.MSG_LEX; private static final String MSG_ORDER = "custom.import.order";
private static final String MSG_NONGROUP_EXPECTED =
CustomImportOrderCheck.MSG_NONGROUP_EXPECTED;
private static final String STATIC = CustomImportOrderCheck.STATIC_RULE_GROUP; /** Shortcuts to make code more compact. */
private static final String STD = CustomImportOrderCheck.STANDARD_JAVA_PACKAGE_RULE_GROUP;
private static final String SPECIAL = CustomImportOrderCheck.SPECIAL_IMPORTS_RULE_GROUP;
private final Class<CustomImportOrderCheck> clazz = CustomImportOrderCheck.class; private final Class<CustomImportOrderCheck> clazz = CustomImportOrderCheck.class;
@ -53,14 +53,16 @@ public class CustomImportOrderTest extends BaseCheckTestSupport {
final String[] expected = { final String[] expected = {
"4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT",
"java.io.File.createTempFile"), "java.io.File.createTempFile"),
"6: " + getCheckMessage(clazz, MSG_LINE_SEPARATOR, "java.awt.Button"), "7: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.Button"),
"8: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Dialog", "java.awt.Frame"), "8: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.Frame"),
"12: " + getCheckMessage(clazz, MSG_LEX, "java.io.File", "javax.swing.JTable"), "9: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.Dialog"),
"13: " + getCheckMessage(clazz, MSG_LEX, "java.io.IOException", "javax.swing.JTable"), "10: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.event.ActionEvent"),
"14: " + getCheckMessage(clazz, MSG_LEX, "java.io.InputStream", "javax.swing.JTable"), "11: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "javax.swing.JComponent"),
"15: " + getCheckMessage(clazz, MSG_LEX, "java.io.Reader", "javax.swing.JTable"), "12: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "javax.swing.JTable"),
"17: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.base.Ascii", "13: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.File"),
"javax.swing.JTable"), "14: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.IOException"),
"15: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.InputStream"),
"16: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.Reader"),
}; };
final Configuration checkConfig = getCheckConfig("CustomImportOrder"); final Configuration checkConfig = getCheckConfig("CustomImportOrder");
@ -76,16 +78,16 @@ public class CustomImportOrderTest extends BaseCheckTestSupport {
final String[] expected = { final String[] expected = {
"4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT",
"java.io.File.createTempFile"), "java.io.File.createTempFile"),
"9: " + getCheckMessage(clazz, MSG_LEX, "java.util.*", "java.util.StringTokenizer"), "7: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.List"),
"11: " + getCheckMessage(clazz, MSG_LEX, "java.util.concurrent.*", "8: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.StringTokenizer"),
"java.util.concurrent.AbstractExecutorService"), "9: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.*"),
"13: " + getCheckMessage(clazz, MSG_LEX, "10: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL,
"com.google.checkstyle.test.chapter2filebasic.rule21filename.*",
"java.util.concurrent.AbstractExecutorService"),
"14: " + getCheckMessage(clazz, MSG_LEX, "com.sun.xml.internal.xsom.impl.scd.Iterators",
"java.util.concurrent.AbstractExecutorService"),
"16: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.reflect.*",
"java.util.concurrent.AbstractExecutorService"), "java.util.concurrent.AbstractExecutorService"),
"11: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.concurrent.*"),
"14: " + getCheckMessage(clazz, MSG_SEPARATOR,
"com.sun.xml.internal.xsom.impl.scd.Iterators"),
"16: " + getCheckMessage(clazz, MSG_ORDER, SPECIAL, STD,
"com.google.common.reflect.*"),
}; };
final Configuration checkConfig = getCheckConfig("CustomImportOrder"); final Configuration checkConfig = getCheckConfig("CustomImportOrder");
@ -99,20 +101,17 @@ public class CustomImportOrderTest extends BaseCheckTestSupport {
public void customImportTest3() throws Exception { public void customImportTest3() throws Exception {
final String[] expected = { final String[] expected = {
"4: " + getCheckMessage(clazz, MSG_LINE_SEPARATOR, "java.awt.Dialog"), "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT",
"5: " + getCheckMessage(clazz, MSG_NONGROUP_EXPECTED, STATIC,
"javax.swing.WindowConstants.*"),
"7: " + getCheckMessage(clazz, MSG_LEX,
"com.google.checkstyle.test.chapter2filebasic.rule21filename.*", "java.awt.Dialog"),
"8: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.reflect.*",
"java.awt.Dialog"),
"9: " + getCheckMessage(clazz, MSG_LEX, "com.sun.xml.internal.xsom.impl.scd.Iterators",
"java.awt.Dialog"),
"11: " + getCheckMessage(clazz, MSG_NONGROUP_EXPECTED, STATIC,
"java.io.File.createTempFile"), "java.io.File.createTempFile"),
"13: " + getCheckMessage(clazz, MSG_LEX, "java.util.*", "java.util.StringTokenizer"), "8: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.StringTokenizer"),
"15: " + getCheckMessage(clazz, MSG_LEX, "java.util.concurrent.*", "9: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.*"),
"10: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL,
"java.util.concurrent.AbstractExecutorService"), "java.util.concurrent.AbstractExecutorService"),
"11: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.concurrent.*"),
"14: " + getCheckMessage(clazz, MSG_SEPARATOR,
"com.sun.xml.internal.xsom.impl.scd.Iterators"),
"16: " + getCheckMessage(clazz, MSG_ORDER, SPECIAL, STD,
"com.google.common.reflect.*"),
}; };
final Configuration checkConfig = getCheckConfig("CustomImportOrder"); final Configuration checkConfig = getCheckConfig("CustomImportOrder");
@ -133,15 +132,4 @@ public class CustomImportOrderTest extends BaseCheckTestSupport {
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }
@Test
public void validGoogleStyleOrderOfImportsTest() throws Exception {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
final Configuration checkConfig = getCheckConfig("CustomImportOrder");
final String filePath = getPath("InputCustomImportOrderNoImports.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,6 @@
package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks; package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_ALONE; import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_ALONE;
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_BREAK_BEFORE;
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_NEW; import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_NEW;
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_SAME; import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_SAME;
@ -30,8 +29,9 @@ import java.io.IOException;
import org.junit.Test; import org.junit.Test;
import com.google.checkstyle.test.base.BaseCheckTestSupport; import com.google.checkstyle.test.base.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck; import com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck;
import com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyOption;
import com.puppycrawl.tools.checkstyle.utils.CommonUtils; import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
public class RightCurlyTest extends BaseCheckTestSupport { public class RightCurlyTest extends BaseCheckTestSupport {
@ -44,47 +44,10 @@ public class RightCurlyTest extends BaseCheckTestSupport {
@Test @Test
public void rightCurlyTestAlone() throws Exception { public void rightCurlyTestAlone() throws Exception {
final String[] expected = { final DefaultConfiguration newCheckConfig = createCheckConfig(RightCurlyCheck.class);
"20:17: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 17), newCheckConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
"32:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13), newCheckConfig.addAttribute("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF");
"79:27: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_BREAK_BEFORE, "}", 27),
};
final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlySame");
final String filePath = getPath("InputRightCurlyOther.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
@Test
public void rightCurlyTestSame() throws Exception {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlySame");
final String filePath = getPath("InputRightCurlySame.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
@Test
public void testRightCurlySameAndLiteralDoDefault() throws Exception {
final String[] expected = {
"62:9: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 9),
"67:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13),
"83:9: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 9),
};
final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlySame");
final String filePath = getPath("InputRightCurlyDoWhile.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
@Test
public void testRightCurlyAloneOther() throws Exception {
final String[] expected = { final String[] expected = {
"97:5: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_ALONE, "}", 5), "97:5: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_ALONE, "}", 5),
"97:6: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_NEW, "}", 6), "97:6: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_NEW, "}", 6),
@ -93,31 +56,34 @@ public class RightCurlyTest extends BaseCheckTestSupport {
"122:6: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_NEW, "}", 6), "122:6: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_NEW, "}", 6),
}; };
final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlyAlone"); final String filePath = getPath("InputRightCurlyOther.java");
final String filePath = getPath("InputRightCurlyOtherAlone.java");
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(newCheckConfig, filePath, expected, warnList);
} }
@Test @Test
public void rightCurlyAloneTestSame() throws Exception { public void rightCurlyTestSame() throws Exception {
final DefaultConfiguration newCheckConfig = createCheckConfig(RightCurlyCheck.class);
newCheckConfig.addAttribute("option", RightCurlyOption.SAME.toString());
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlyAlone");
final String filePath = getPath("InputRightCurlySame.java"); final String filePath = getPath("InputRightCurlySame.java");
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(newCheckConfig, filePath, expected, warnList);
} }
@Test @Test
public void testRightCurlyAloneSameAndLiteralDo() throws Exception { public void testRightCurlySameAndLiteralDo() throws Exception {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; final DefaultConfiguration checkConfig = createCheckConfig(RightCurlyCheck.class);
checkConfig.addAttribute("option", RightCurlyOption.SAME.toString());
final Configuration checkConfig = getCheckConfig("RightCurly", "RightCurlyAlone"); checkConfig.addAttribute("tokens", "LITERAL_DO");
final String filePath = getPath("InputRightCurlyDoWhileAlone.java"); final String[] expected = {
"62:9: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 9),
"67:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13),
"83:9: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 9),
};
final String filePath = getPath("InputRightCurlyDoWhile.java");
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -25,8 +25,10 @@ import java.io.IOException;
import org.junit.Test; import org.junit.Test;
import com.google.checkstyle.test.base.BaseCheckTestSupport; import com.google.checkstyle.test.base.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.api.Configuration;
import com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck; import com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck;
import com.puppycrawl.tools.checkstyle.checks.whitespace.WrapOption;
public class OperatorWrapTest extends BaseCheckTestSupport { public class OperatorWrapTest extends BaseCheckTestSupport {
@ -43,25 +45,25 @@ public class OperatorWrapTest extends BaseCheckTestSupport {
final String messageKey = "line.new"; final String messageKey = "line.new";
final String[] expected = { final String[] expected = {
"11:27: " + getCheckMessage(clazz, messageKey, "+"), "10:27: " + getCheckMessage(clazz, messageKey, "+"),
"12:28: " + getCheckMessage(clazz, messageKey, "-"), "11:28: " + getCheckMessage(clazz, messageKey, "-"),
"20:27: " + getCheckMessage(clazz, messageKey, "&&"), "19:27: " + getCheckMessage(clazz, messageKey, "&&"),
"62:42: " + getCheckMessage(clazz, messageKey, "?"), "53:42: " + getCheckMessage(clazz, messageKey, "?"),
"66:27: " + getCheckMessage(clazz, messageKey, "!="), "57:27: " + getCheckMessage(clazz, messageKey, "!="),
"72:30: " + getCheckMessage(clazz, messageKey, "=="), "63:30: " + getCheckMessage(clazz, messageKey, "=="),
"78:27: " + getCheckMessage(clazz, messageKey, ">"), "69:27: " + getCheckMessage(clazz, messageKey, ">"),
"84:35: " + getCheckMessage(clazz, messageKey, "||"), "75:35: " + getCheckMessage(clazz, messageKey, "||"),
"107:46: " + getCheckMessage(clazz, messageKey, "?"), "98:46: " + getCheckMessage(clazz, messageKey, "?"),
"111:31: " + getCheckMessage(clazz, messageKey, "!="), "102:31: " + getCheckMessage(clazz, messageKey, "!="),
"117:34: " + getCheckMessage(clazz, messageKey, "=="), "108:34: " + getCheckMessage(clazz, messageKey, "=="),
"123:31: " + getCheckMessage(clazz, messageKey, ">"), "114:31: " + getCheckMessage(clazz, messageKey, ">"),
"129:39: " + getCheckMessage(clazz, messageKey, "||"), "120:39: " + getCheckMessage(clazz, messageKey, "||"),
"153:46: " + getCheckMessage(clazz, messageKey, "?"), "144:46: " + getCheckMessage(clazz, messageKey, "?"),
"157:31: " + getCheckMessage(clazz, messageKey, "!="), "148:31: " + getCheckMessage(clazz, messageKey, "!="),
"163:34: " + getCheckMessage(clazz, messageKey, "=="), "154:34: " + getCheckMessage(clazz, messageKey, "=="),
"169:31: " + getCheckMessage(clazz, messageKey, ">"), "160:31: " + getCheckMessage(clazz, messageKey, ">"),
"175:39: " + getCheckMessage(clazz, messageKey, "||"), "166:39: " + getCheckMessage(clazz, messageKey, "||"),
"194:38: " + getCheckMessage(clazz, messageKey, "?"), "185:38: " + getCheckMessage(clazz, messageKey, "?"),
}; };
final Configuration checkConfig = getCheckConfig("OperatorWrap"); final Configuration checkConfig = getCheckConfig("OperatorWrap");
@ -71,4 +73,56 @@ public class OperatorWrapTest extends BaseCheckTestSupport {
verify(checkConfig, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }
@Test
public void operatorWrapTestAssign() throws Exception {
final DefaultConfiguration newCheckConfig = createCheckConfig(OperatorWrapCheck.class);
newCheckConfig.addAttribute("option", WrapOption.EOL.toString());
newCheckConfig.addAttribute("tokens", "ASSIGN, DIV_ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN,"
+ "STAR_ASSIGN, MOD_ASSIGN, SR_ASSIGN, BSR_ASSIGN, SL_ASSIGN, BXOR_ASSIGN,"
+ "BOR_ASSIGN, BAND_ASSIGN");
final String messageKey = "line.previous";
final Class<OperatorWrapCheck> clazz = OperatorWrapCheck.class;
final String[] expected = {
"28:13: " + getCheckMessage(clazz, messageKey, "="),
"177:9: " + getCheckMessage(clazz, messageKey, "="),
"207:14: " + getCheckMessage(clazz, messageKey, "+="),
"211:14: " + getCheckMessage(clazz, messageKey, "-="),
"215:14: " + getCheckMessage(clazz, messageKey, "/="),
"219:14: " + getCheckMessage(clazz, messageKey, "*="),
"223:14: " + getCheckMessage(clazz, messageKey, "%="),
"227:14: " + getCheckMessage(clazz, messageKey, "^="),
"231:14: " + getCheckMessage(clazz, messageKey, "|="),
"235:14: " + getCheckMessage(clazz, messageKey, "&="),
"239:13: " + getCheckMessage(clazz, messageKey, ">>="),
"243:13: " + getCheckMessage(clazz, messageKey, ">>>="),
"247:13: " + getCheckMessage(clazz, messageKey, "<<="),
"257:18: " + getCheckMessage(clazz, messageKey, "+="),
"261:18: " + getCheckMessage(clazz, messageKey, "-="),
"265:18: " + getCheckMessage(clazz, messageKey, "/="),
"269:18: " + getCheckMessage(clazz, messageKey, "*="),
"273:18: " + getCheckMessage(clazz, messageKey, "%="),
"277:18: " + getCheckMessage(clazz, messageKey, "^="),
"281:18: " + getCheckMessage(clazz, messageKey, "|="),
"285:18: " + getCheckMessage(clazz, messageKey, "&="),
"289:17: " + getCheckMessage(clazz, messageKey, ">>="),
"293:17: " + getCheckMessage(clazz, messageKey, ">>>="),
"297:17: " + getCheckMessage(clazz, messageKey, "<<="),
"308:18: " + getCheckMessage(clazz, messageKey, "+="),
"312:18: " + getCheckMessage(clazz, messageKey, "-="),
"316:18: " + getCheckMessage(clazz, messageKey, "/="),
"320:18: " + getCheckMessage(clazz, messageKey, "*="),
"324:18: " + getCheckMessage(clazz, messageKey, "%="),
"328:18: " + getCheckMessage(clazz, messageKey, "^="),
"332:18: " + getCheckMessage(clazz, messageKey, "|="),
"336:18: " + getCheckMessage(clazz, messageKey, "&="),
"340:17: " + getCheckMessage(clazz, messageKey, ">>="),
"344:17: " + getCheckMessage(clazz, messageKey, ">>>="),
"348:17: " + getCheckMessage(clazz, messageKey, "<<="),
};
final String filePath = getPath("InputOperatorWrapAssign.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(newCheckConfig, filePath, expected, warnList);
}
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -37,30 +37,16 @@ public class SeparatorWrapTest extends BaseCheckTestSupport {
} }
@Test @Test
public void separatorWrapDotTest() throws Exception { public void separatorWrapTest() throws Exception {
final String[] expected = { final String[] expected = {
"28:30: " + getCheckMessage(SeparatorWrapCheck.class, "line.new", "."), "28:30: " + getCheckMessage(SeparatorWrapCheck.class, "line.new", "."),
}; };
final Configuration checkConfig = getCheckConfig("SeparatorWrap", "SeparatorWrapDot"); final Configuration checkConfig = getCheckConfig("SeparatorWrap");
final String filePath = getPath("InputSeparatorWrap.java"); final String filePath = getPath("InputSeparatorWrap.java");
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }
@Test
public void separatorWrapCommaTest() throws Exception {
final String[] expected = {
"31:17: " + getCheckMessage(SeparatorWrapCheck.class, "line.previous", ","),
};
final Configuration checkConfig = getCheckConfig("SeparatorWrap", "SeparatorWrapComma");
final String filePath = getPath("InputSeparatorWrapComma.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,61 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////
package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import com.google.checkstyle.test.base.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.api.Configuration;
import com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck;
public class MethodParamPadTest extends BaseCheckTestSupport {
@Override
protected String getPath(String fileName) throws IOException {
return super.getPath("chapter4formatting" + File.separator + "rule462horizontalwhitespace"
+ File.separator + fileName);
}
@Test
public void operatorWrapTest() throws Exception {
final Class<MethodParamPadCheck> clazz = MethodParamPadCheck.class;
final String messageKeyPreceded = "ws.preceded";
final String[] expected = {
"11:32: " + getCheckMessage(clazz, messageKeyPreceded, "("),
"13:15: " + getCheckMessage(clazz, messageKeyPreceded, "("),
"20:24: " + getCheckMessage(clazz, messageKeyPreceded, "("),
"29:39: " + getCheckMessage(clazz, messageKeyPreceded, "("),
"35:16: " + getCheckMessage(clazz, messageKeyPreceded, "("),
"41:21: " + getCheckMessage(clazz, messageKeyPreceded, "("),
"47:18: " + getCheckMessage(clazz, messageKeyPreceded, "("),
"52:36: " + getCheckMessage(clazz, messageKeyPreceded, "("),
};
final Configuration checkConfig = getCheckConfig("MethodParamPad");
final String filePath = getPath("InputMethodParamPad.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
}

View File

@ -1,118 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////
package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import com.google.checkstyle.test.base.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.api.Configuration;
import com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck;
public class ParenPadTest extends BaseCheckTestSupport {
@Override
protected String getPath(String fileName) throws IOException {
return super.getPath("chapter4formatting" + File.separator + "rule462horizontalwhitespace"
+ File.separator + fileName);
}
@Test
public void methodParenTest() throws Exception {
final Class<ParenPadCheck> clazz = ParenPadCheck.class;
final String messageKeyPreceded = "ws.preceded";
final String messageKeyFollowed = "ws.followed";
final String[] expected = {
"44:27: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"44:27: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"45:18: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"48:27: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"49:19: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"49:19: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"52:27: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"53:21: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"54:18: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"54:52: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"54:52: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"57:26: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"58:22: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"59:24: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"60:26: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"60:51: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"60:57: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"61:29: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"62:43: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"63:41: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"65:43: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"78:28: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"78:28: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"79:19: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"82:33: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"83:19: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"83:19: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"86:29: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"87:35: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"88:51: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"88:51: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"88:53: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"90:38: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"91:32: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"92:35: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"93:30: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"94:60: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"94:62: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"94:69: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"95:34: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"96:47: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"97:42: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"99:44: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"112:17: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"113:23: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"113:25: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"113:31: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"114:26: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"114:28: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"114:34: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"114:50: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"115:26: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"115:28: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"115:35: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"115:53: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"115:55: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"119:17: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"119:22: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"123:30: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"123:44: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"126:22: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"126:22: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
"130:19: " + getCheckMessage(clazz, messageKeyFollowed, "("),
"130:19: " + getCheckMessage(clazz, messageKeyPreceded, ")"),
};
final Configuration checkConfig = getCheckConfig("ParenPad");
final String filePath = getPath("InputParenPad.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
}

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -64,9 +64,6 @@ public class WhitespaceAroundTest extends BaseCheckTestSupport {
"118:20: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "/"), "118:20: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "/"),
"147:15: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "assert"), "147:15: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "assert"),
"150:20: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ":"), "150:20: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, ":"),
"249:14: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "->"),
"250:17: " + getCheckMessage(checkConfig.getMessages(), msgFollowed, "->"),
"250:17: " + getCheckMessage(checkConfig.getMessages(), msgPreceded, "{"),
}; };
final String filePath = getPath("InputWhitespaceAroundBasic.java"); final String filePath = getPath("InputWhitespaceAroundBasic.java");

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -41,8 +41,7 @@ public class AnnotationLocationTest extends BaseCheckTestSupport {
final Class<AnnotationLocationCheck> clazz = AnnotationLocationCheck.class; final Class<AnnotationLocationCheck> clazz = AnnotationLocationCheck.class;
getCheckMessage(clazz, "annotation.location.alone"); getCheckMessage(clazz, "annotation.location.alone");
final Configuration checkConfig = getCheckConfig("AnnotationLocation", final Configuration checkConfig = getCheckConfig("AnnotationLocation");
"AnnotationLocationMostCases");
final String msgLocationAlone = "annotation.location.alone"; final String msgLocationAlone = "annotation.location.alone";
final String msgLocation = "annotation.location"; final String msgLocation = "annotation.location";
@ -65,23 +64,4 @@ public class AnnotationLocationTest extends BaseCheckTestSupport {
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }
@Test
public void annotationTestVariables() throws Exception {
final Class<AnnotationLocationCheck> clazz = AnnotationLocationCheck.class;
getCheckMessage(clazz, "annotation.location.alone");
final Configuration checkConfig = getCheckConfig("AnnotationLocation",
"AnnotationLocationVariables");
final String msgLocation = "annotation.location";
final String[] expected = {
"63: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "7", "4"),
};
final String filePath = getPath("InputAnnotationLocationVariables.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -22,40 +22,29 @@ package com.google.checkstyle.test.chapter5naming.rule51identifiernames;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import com.google.checkstyle.test.base.BaseCheckTestSupport; import com.google.checkstyle.test.base.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.api.Configuration;
public class CatchParameterNameTest extends BaseCheckTestSupport { public class CatchParameterNameTest extends BaseCheckTestSupport {
private static Configuration checkConfig;
private static String format;
@Override @Override
protected String getPath(String fileName) throws IOException { protected String getPath(String fileName) throws IOException {
return super.getPath("chapter5naming" + File.separator + "rule51identifiernames" return super.getPath("chapter5naming" + File.separator + "rule51identifiernames"
+ File.separator + fileName); + File.separator + fileName);
} }
@BeforeClass
public static void setConfigurationBuilder() throws CheckstyleException {
checkConfig = getCheckConfig("CatchParameterName");
format = checkConfig.getAttribute("format");
}
@Test @Test
public void catchParameterNameTest() throws Exception { public void catchParameterNameTest() throws Exception {
final Configuration checkConfig = getCheckConfig("CatchParameterName");
final String msgKey = "name.invalidPattern"; final String msgKey = "name.invalidPattern";
final String format = "^[a-z][a-z0-9][a-zA-Z0-9]*$";
final String[] expected = { final String[] expected = {
"6:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "e", format),
"24:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "t", format),
"47:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "iException", format), "47:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "iException", format),
"50:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "ex_1", format), "50:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "x", format),
"53:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "eX", format),
"56:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "eXX", format),
"59:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "x_y_z", format),
"62:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "Ex", format),
}; };
final String filePath = getPath("InputCatchParameterName.java"); final String filePath = getPath("InputCatchParameterName.java");

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -36,7 +36,7 @@ public class PackageNameTest extends BaseCheckTestSupport {
private static Configuration checkConfig; private static Configuration checkConfig;
private static String format; private static String format;
private String getPath(String packageName, String fileName) throws IOException { protected String getPath(String packageName, String fileName) throws IOException {
return getPath("chapter5naming" + File.separator + "rule521" + packageName return getPath("chapter5naming" + File.separator + "rule521" + packageName
+ File.separator + fileName); + File.separator + fileName);
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -21,9 +21,7 @@ package com.google.checkstyle.test.chapter5naming.rule526parameternames;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -35,7 +33,7 @@ public class ParameterNameTest extends BaseCheckTestSupport {
private static final String MSG_KEY = "name.invalidPattern"; private static final String MSG_KEY = "name.invalidPattern";
private static String format; private static String format;
private static Configuration config; private static Configuration checkConfig;
@Override @Override
protected String getPath(String fileName) throws IOException { protected String getPath(String fileName) throws IOException {
@ -45,36 +43,31 @@ public class ParameterNameTest extends BaseCheckTestSupport {
@BeforeClass @BeforeClass
public static void setConfigurationBuilder() throws CheckstyleException { public static void setConfigurationBuilder() throws CheckstyleException {
final List<Configuration> configs = getCheckConfigs("ParameterName"); checkConfig = getCheckConfig("ParameterName");
format = checkConfig.getAttribute("format");
Assert.assertEquals(configs.size(), 1);
config = configs.get(0);
format = config.getAttribute("format");
} }
@Test @Test
public void generalParameterNameTest() throws Exception { public void parameterNameTest() throws Exception {
final String[] expected = { final String[] expected = {
"10:21: " + getCheckMessage(config.getMessages(), MSG_KEY, "bB", format), "8:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "$arg1", format),
"33:22: " + getCheckMessage(config.getMessages(), MSG_KEY, "llll_llll", format), "9:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "ar$g2", format),
"34:21: " + getCheckMessage(config.getMessages(), MSG_KEY, "bB", format), "10:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "arg3$", format),
"64:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "$arg1", format), "11:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "a_rg4", format),
"65:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "ar$g2", format), "12:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "_arg5", format),
"66:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "arg3$", format), "13:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "arg6_", format),
"67:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "a_rg4", format), "14:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aArg7", format),
"68:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "_arg5", format), "15:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aArg8", format),
"69:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "arg6_", format), "16:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aar_g", format),
"70:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "aArg7", format), "26:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bB", format),
"71:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "aArg8", format), "49:22: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "llll_llll", format),
"72:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "aar_g", format), "50:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bB", format),
}; };
final String filePath = getPath("InputParameterName.java"); final String filePath = getPath("InputParameterNameSimple.java");
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(config, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -51,6 +51,7 @@ public class LocalVariableNameTest extends BaseCheckTestSupport {
public void localVariableNameTest() throws Exception { public void localVariableNameTest() throws Exception {
final String[] expected = { final String[] expected = {
"26:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "a", format),
"27:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aA", format), "27:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aA", format),
"28:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "a1_a", format), "28:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "a1_a", format),
"29:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "A_A", format), "29:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "A_A", format),
@ -73,6 +74,7 @@ public class LocalVariableNameTest extends BaseCheckTestSupport {
public void oneCharTest() throws Exception { public void oneCharTest() throws Exception {
final String[] expected = { final String[] expected = {
"15:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "i", format),
"21:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "I_ndex", format), "21:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "I_ndex", format),
"45:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "i_ndex", format), "45:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "i_ndex", format),
"49:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "ii_i1", format), "49:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "ii_i1", format),

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -42,7 +42,7 @@ public class AbbreviationAsWordInNameTest extends BaseCheckTestSupport {
@Test @Test
public void abbreviationAsWordInNameTest() throws Exception { public void abbreviationAsWordInNameTest() throws Exception {
final int maxCapitalCount = 2; final int maxCapitalCount = 1;
final String[] expected = { final String[] expected = {
"50: " + getWarningMessage("newCustomerID", maxCapitalCount), "50: " + getWarningMessage("newCustomerID", maxCapitalCount),

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -25,6 +25,7 @@ import java.io.IOException;
import org.junit.Test; import org.junit.Test;
import com.google.checkstyle.test.base.BaseCheckTestSupport; import com.google.checkstyle.test.base.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.api.Configuration;
import com.puppycrawl.tools.checkstyle.checks.javadoc.SingleLineJavadocCheck; import com.puppycrawl.tools.checkstyle.checks.javadoc.SingleLineJavadocCheck;
@ -51,10 +52,26 @@ public class SingleLineJavadocTest extends BaseCheckTestSupport {
"41: " + msg, "41: " + msg,
}; };
final Configuration checkConfig = getCheckConfig("SingleLineJavadoc"); final DefaultConfiguration checkConfig = createCheckConfig(SingleLineJavadocCheck.class);
checkConfig.addAttribute("ignoreInlineTags", "false");
final String filePath = getPath("InputSingleLineJavadocCheck.java"); final String filePath = getPath("InputSingleLineJavadocCheck.java");
final Integer[] warnList = getLinesWithWarn(filePath); final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList); verify(checkConfig, filePath, expected, warnList);
} }
@Test(expected = Exception.class)
public void customInlineTagTest() throws Exception {
final String msg = getCheckMessage(SingleLineJavadocCheck.class, "singleline.javadoc");
final Configuration checkConfig = getCheckConfig("SingleLineJavadocCheck");
final String filePath = getPath("InputSingleLineJavadocCheckError.java");
final String[] expected = {
"4: " + msg,
};
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
}
} }

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules. // checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors. // Copyright (C) 2001-2016 the original author or authors.
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public

View File

@ -14,7 +14,7 @@ public class InputIllegalTokenText
public String wrongEscapeSequences() public String wrongEscapeSequences()
{ {
final String r1 = "\u0008"; //ok final String r1 = "\u0008"; //warn
final String r2 = "\u0009"; //warn final String r2 = "\u0009"; //warn
final String r3 = "\u000csssdfsd"; //warn final String r3 = "\u000csssdfsd"; //warn
final String r4 = "\u1111sdfsd\444"; // ok final String r4 = "\u1111sdfsd\444"; // ok
@ -39,7 +39,7 @@ public class InputIllegalTokenText
public void specialCharsWithWarn() public void specialCharsWithWarn()
{ {
String r1 = "\\u0008"; //ok String r1 = "\\u0008"; // warn
String r2 = "\\u0009"; // warn String r2 = "\\u0009"; // warn
String r3 = "\\u000a"; // warn String r3 = "\\u000a"; // warn
String r4 = "\\u000c"; // warn String r4 = "\\u000c"; // warn
@ -65,7 +65,7 @@ public class InputIllegalTokenText
{ {
public String wrongEscapeSequences() public String wrongEscapeSequences()
{ {
final String r1 = "\u0008"; //ok final String r1 = "\u0008"; //warn
final String r2 = "\u0009"; //warn final String r2 = "\u0009"; //warn
final String r3 = "\u000csssdfsd"; //warn final String r3 = "\u000csssdfsd"; //warn
final String r4 = "\u1111sdfsd\444"; //ok final String r4 = "\u1111sdfsd\444"; //ok
@ -90,7 +90,7 @@ public class InputIllegalTokenText
public void specialCharsWithWarn() public void specialCharsWithWarn()
{ {
String r1 = "\\u0008"; //ok String r1 = "\\u0008"; // warn
String r2 = "\\u0009"; // warn String r2 = "\\u0009"; // warn
String r3 = "\\u000a"; // warn String r3 = "\\u000a"; // warn
String r4 = "\\u000c"; // warn String r4 = "\\u000c"; // warn
@ -115,7 +115,7 @@ public class InputIllegalTokenText
Inner anoInner = new Inner(){ Inner anoInner = new Inner(){
public String wrongEscapeSequences() public String wrongEscapeSequences()
{ {
final String r1 = "\u0008"; //ok final String r1 = "\u0008"; //warn
final String r2 = "\u0009"; //warn final String r2 = "\u0009"; //warn
final String r3 = "\u000csssdfsd"; //warn final String r3 = "\u000csssdfsd"; //warn
final String r4 = "\u1111sdfsd\444"; //ok final String r4 = "\u1111sdfsd\444"; //ok
@ -140,7 +140,7 @@ public class InputIllegalTokenText
public void specialCharsWithWarn() public void specialCharsWithWarn()
{ {
String r1 = "\\u0008"; //ok String r1 = "\\u0008"; // warn
String r2 = "\\u0009"; // warn String r2 = "\\u0009"; // warn
String r3 = "\\u000a"; // warn String r3 = "\\u000a"; // warn
String r4 = "\\u000c"; // warn String r4 = "\\u000c"; // warn

View File

@ -3,17 +3,20 @@ package com.google.checkstyle.test.chapter3filestructure.rule333orderingandspaci
import static java.io.File.createTempFile; import static java.io.File.createTempFile;
import static java.awt.Button.ABORT; //warn import static java.awt.Button.ABORT; //warn
import static javax.swing.WindowConstants.*; import static javax.swing.WindowConstants.*;
import java.awt.Button; //warn import java.awt.Button; //warn
import java.awt.Frame; import java.awt.Frame; //warn
import java.awt.Dialog; //warn import java.awt.Dialog; //warn
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent; //warn
import javax.swing.JComponent; import javax.swing.JComponent; //warn
import javax.swing.JTable; import javax.swing.JTable; //warn
import java.io.File; //warn import java.io.File; //warn
import java.io.IOException; //warn import java.io.IOException; //warn
import java.io.InputStream; //warn import java.io.InputStream; //warn
import java.io.Reader; //warn import java.io.Reader; //warn
import com.google.common.base.Ascii; //warn
import com.google.common.base.Ascii;
public class InputCustomImportOrder1 {} public class InputCustomImportOrder1 {}

View File

@ -4,13 +4,13 @@ import static java.io.File.createTempFile;
import static java.awt.Button.ABORT; //warn import static java.awt.Button.ABORT; //warn
import static javax.swing.WindowConstants.*; import static javax.swing.WindowConstants.*;
import java.util.List; import java.util.List; //warn
import java.util.StringTokenizer; import java.util.StringTokenizer; //warn
import java.util.*; //warn import java.util.*; //warn
import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.AbstractExecutorService; //warn
import java.util.concurrent.*; //warn import java.util.concurrent.*; //warn
import com.google.checkstyle.test.chapter2filebasic.rule21filename.*; //warn import com.google.checkstyle.test.chapter2filebasic.rule21filename.*;
import com.sun.xml.internal.xsom.impl.scd.Iterators; //warn import com.sun.xml.internal.xsom.impl.scd.Iterators; //warn
import com.google.common.reflect.*; //warn import com.google.common.reflect.*; //warn

View File

@ -1,18 +1,19 @@
package com.google.checkstyle.test.chapter3filestructure.rule333orderingandspacing; package com.google.checkstyle.test.chapter3filestructure.rule333orderingandspacing;
import static java.awt.Button.ABORT; import static java.io.File.createTempFile;
import java.awt.Dialog; //warn import static java.awt.Button.ABORT; //warn
import static javax.swing.WindowConstants.*; //warn import static javax.swing.WindowConstants.*;
import com.google.checkstyle.test.chapter2filebasic.rule21filename.*; //warn
import com.google.common.reflect.*; //warn import java.util.StringTokenizer; //warn
import com.sun.xml.internal.xsom.impl.scd.Iterators; //warn
import java.io.File;
import static java.io.File.createTempFile; //warn
import java.util.StringTokenizer;
import java.util.*; //warn import java.util.*; //warn
import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.AbstractExecutorService; //warn
import java.util.concurrent.*; //warn import java.util.concurrent.*; //warn
import com.google.checkstyle.test.chapter2filebasic.rule21filename.*;
import com.sun.xml.internal.xsom.impl.scd.Iterators; //warn
import com.google.common.reflect.*; //warn
public class InputCustomImportOrder3 { public class InputCustomImportOrder3 {
} }

View File

@ -1,4 +0,0 @@
package com.google.checkstyle.test.chapter3filestructure.rule333orderingandspacing;
public class InputCustomImportOrderNoImports {
}

View File

@ -6,14 +6,16 @@ import static com.puppycrawl.tools.checkstyle.utils.AnnotationUtility.getAnnotat
import com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck; import com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck;
import com.puppycrawl.tools.checkstyle.checks.design.ThrowsCountCheck; import com.puppycrawl.tools.checkstyle.checks.design.ThrowsCountCheck;
import com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck; import com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck;
import com.sun.accessibility.internal.resources.*; import com.sun.accessibility.internal.resources.*;
import org.apache.commons.beanutils.converters.ArrayConverter;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet; import java.util.BitSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import javax.accessibility.Accessible; import javax.accessibility.Accessible;
import org.apache.commons.beanutils.converters.ArrayConverter;
public class InputCustomImportOrderValid { public class InputCustomImportOrderValid {
} }

View File

@ -1,93 +0,0 @@
package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
import java.util.Scanner;
/**
* Test input for GitHub issue #3090.
* https://github.com/checkstyle/checkstyle/issues/3090
*/
public class InputRightCurlyDoWhileAlone {
public void foo1() {
do {
} while (true);
}
public void foo2() {
int i = 1;
while (i < 5) {
String.CASE_INSENSITIVE_ORDER.equals(i + " ");
i++;
}
}
public void foo3() {
int i = 1;
do {
i++;
String.CASE_INSENSITIVE_ORDER.equals(i + " ");
} while (i < 5);
}
public void foo4() {
int prog, user;
prog = (int)(Math.random() * 10) + 1;
Scanner input = new Scanner(System.in, "utf-8");
if( input.hasNextInt() ) {
do {
user = input.nextInt();
if(user == prog) {
String.CASE_INSENSITIVE_ORDER.equals("Good!");
} else {
if (user > 0 && user <= 10) {
String.CASE_INSENSITIVE_ORDER.equals("Bad! ");
if( prog < user ) {
String.CASE_INSENSITIVE_ORDER.equals("My number is less than yours.");
} else {
String.CASE_INSENSITIVE_ORDER.equals("My number is greater than yours.");
}
} else {
String.CASE_INSENSITIVE_ORDER.equals("Error!");
}
}
} while( user != prog );
} else {
String.CASE_INSENSITIVE_ORDER.equals("Error!");
}
String.CASE_INSENSITIVE_ORDER.equals("Goodbye!");
}
public void foo5() {
do {
} // ok - for alone
while (true);
}
public void foo6() {
do {} // ok - for alone
while (true);
}
public void foo7() {
do
{
} while (true);
}
public void foo8() {
do
{
} // ok - for alone
while
(true);
}
public void foo9() {
do {} while (true);
}
}

View File

@ -17,7 +17,7 @@ class InputRightCurlyOther
} else if (x < 0) { //ok } else if (x < 0) { //ok
; ;
} //warn }
else else
{ {
break; break;
@ -29,7 +29,7 @@ class InputRightCurlyOther
default: default:
break; break;
} //ok } //ok
} //warn }
catch (Exception e) catch (Exception e)
{ {
break; break;
@ -76,7 +76,7 @@ class InputRightCurlyOther
boolean flag = true; boolean flag = true;
if (flag) { if (flag) {
System.identityHashCode("heh"); System.identityHashCode("heh");
flag = !flag; } System. //warn flag = !flag; } System.
identityHashCode("Xe-xe"); identityHashCode("Xe-xe");
@ -94,7 +94,7 @@ class FooCtor
public FooCtor() public FooCtor()
{ {
i = 1; i = 1;
}} //ok }} //warn
/** /**
* Test input for closing brace if that brace terminates * Test input for closing brace if that brace terminates
@ -105,7 +105,7 @@ class FooMethod
public void fooMethod() public void fooMethod()
{ {
int i = 1; int i = 1;
}} //ok }} //warn
/** /**
* Test input for closing brace if that brace terminates * Test input for closing brace if that brace terminates
@ -119,7 +119,7 @@ class FooInner
{ {
} }
}} //ok }} //warn
class EnumContainer { class EnumContainer {
private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS } // ok private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS } // ok

View File

@ -1,145 +0,0 @@
package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
class InputRightCurlyOtherAlone
{
/** @see test method **/
int foo() throws InterruptedException
{
int x = 1;
int a = 2;
while (true)
{
try
{
if (x > 0)
{
break;
} else if (x < 0) { //ok
;
} //ok - for alone config
else
{
break;
}//ok
switch (a)
{
case 0:
break;
default:
break;
} //ok
} //ok - for alone config
catch (Exception e)
{
break;
}//ok
}//ok
synchronized (this)
{
do
{
x = 2;
} while (x == 2); //ok
}//ok
this.wait(666
); // Bizarre, but legal
for (int k = 0; k < 1; k++)
{
String innerBlockVariable = "";
}//ok
if (System.currentTimeMillis() > 1000)
return 1;
else
return 2;
}//ok
static
{
int x = 1;
}//ok
public enum GreetingsEnum
{
HELLO,
GOODBYE
}; //ok
void method2()
{
boolean flag = true;
if (flag) {
System.identityHashCode("heh");
flag = !flag; } System. //ok for alone config
identityHashCode("Xe-xe");
if (flag) { System.identityHashCode("some foo"); }
} //ok
} //ok
/**
* Test input for closing brace if that brace terminates
* a statement or the body of a constructor.
*/
class FooCtorAlone
{
int i;
public FooCtorAlone()
{
i = 1;
}} //warn
/**
* Test input for closing brace if that brace terminates
* a statement or the body of a method.
*/
class FooMethodAlone
{
public void fooMethod()
{
int i = 1;
}} //warn
/**
* Test input for closing brace if that brace terminates
* a statement or the body of a named class.
*/
class FooInnerAlone
{
class InnerFoo
{
public void fooInnerMethod ()
{
}
}} //warn
class EnumContainerAlone {
private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS } // ok
}
class WithArraysAlone {
String[] s = {""}; // ok
String[] empty = {}; // ok
String[] s1 = {
"foo", "foo",
}; // ok
String[] s2 =
{
"foo", "foo",
}; // ok
String[] s3 =
{
"foo",
"foo",
}; // ok
String[] s4 =
{"foo", "foo"}; // ok
}

View File

@ -1,6 +1,5 @@
package com.google.checkstyle.test.chapter4formatting.rule451wheretobreak; package com.google.checkstyle.test.chapter4formatting.rule451wheretobreak;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -21,14 +20,6 @@ class InputOperatorWrap
false; false;
y = false y = false
&& true; && true;
/* Note: The three tests below will be used when issue #3381 is closed */
Arrays.sort(null, String
::
compareToIgnoreCase);
Arrays.sort(null, String:: /*(warn)*/
compareToIgnoreCase);
Arrays.sort(null, String
::compareToIgnoreCase);
} }
void testAssignment() void testAssignment()

View File

@ -0,0 +1,351 @@
package com.google.checkstyle.test.chapter4formatting.rule451wheretobreak;
import java.util.HashMap;
import java.util.Map;
class InputOperatorWrapAssign
{
void test()
{
int x = 1 +
2 -
3
-
4;
x = x + 2;
boolean y = true
&&
false;
y = true &&
false;
y = false
&& true;
}
void testAssignment()
{
int x
= 0; //warn
int y =
0;
}
<
T extends Comparable &
java.io.Serializable
>
void testGenerics1()
{
Comparable
<
String
>
c = new String();
Map<String, String> map = new HashMap<String, String>();
boolean flag = false;
int init = 9;
for (Map.Entry<String, String> entry :
map.entrySet())
{
int i = flag == true ?
1 : 2;
}
if (init !=
9)
{
}
while (init ==
10)
{
}
if (init >
10)
{
} else {}
while (init < 10 ||
!flag) {
}
}
class Inner {
void testGenerics1
()
{
Comparable
<
String
>
c = new String();
Map<String, String> map = new HashMap<String, String>();
boolean flag = false;
int init = 9;
/*ok*/ for (Map.Entry<String, String> entry :
map.entrySet())
{
int i = flag == true ?
1 : 2;
}
if (init !=
9)
{
}
while (init ==
10)
{
}
if (init >
10)
{
} else {}
while (init < 10 ||
!flag) {
}
}
}
Inner anon = new Inner
(){
void testGenerics1
()
{
Comparable
<
String
>
c = new String();
Map<String, String> map = new HashMap<String, String>();
boolean flag = false;
int init = 9;
/*ok*/ for (Map.Entry<String, String> entry :
map.entrySet())
{
int i = flag == true ?
1 : 2;
}
if (init !=
9)
{
}
while (init ==
10)
{
}
if (init >
10)
{
} else {}
while (init < 10 ||
!flag) {
}
}
};
}
class AsInput3 {
int abc = 0;
String string
= "string"; // warn
double PI = // ok
3.1415;
}
class Ternary4 {
void foo() {
boolean flag = true;
int i = flag == true ?
1 :
2;
int i2 = flag == true
?
1
:
2;
int i3 = flag == true
? 1
: 2;
}
}
class AssignClass5 {
void foo() {
int i = 0;
int j = 0;
i +=
1;
j
+= 2; //warn
i -=
1;
j
-= 2; //warn
i /=
1;
j
/= 2; //warn
i *=
1;
j
*= 2; //warn
i %=
1;
j
%= 2; //warn
i ^=
1;
j
^= 2; //warn
i |=
1;
j
|= 2; //warn
i &=
1;
j
&= 2; //warn
i >>=
1;
j
>>= 2; //warn
i >>>=
1;
j
>>>= 2; //warn
i <<=
1;
j
<<= 2; //warn
}
class InnerClass {
void foo() {
int i = 0;
int j = 0;
i +=
1;
j
+= 2; //warn
i -=
1;
j
-= 2; //warn
i /=
1;
j
/= 2; //warn
i *=
1;
j
*= 2; //warn
i %=
1;
j
%= 2; //warn
i ^=
1;
j
^= 2; //warn
i |=
1;
j
|= 2; //warn
i &=
1;
j
&= 2; //warn
i >>=
1;
j
>>= 2; //warn
i >>>=
1;
j
>>>= 2; //warn
i <<=
1;
j
<<= 2; //warn
}
}
InnerClass anon = new InnerClass() {
void foo() {
int i = 0;
int j = 0;
i +=
1;
j
+= 2; //warn
i -=
1;
j
-= 2; //warn
i /=
1;
j
/= 2; //warn
i *=
1;
j
*= 2; //warn
i %=
1;
j
%= 2; //warn
i ^=
1;
j
^= 2; //warn
i |=
1;
j
|= 2; //warn
i &=
1;
j
&= 2; //warn
i >>=
1;
j
>>= 2; //warn
i >>>=
1;
j
>>>= 2; //warn
i <<=
1;
j
<<= 2; //warn
}
};
}

View File

@ -1,45 +0,0 @@
package com.google.checkstyle.test.chapter4formatting.rule451wheretobreak;
public class InputSeparatorWrapComma {
public void goodCase()
{
int i = 0;
String s = "ffffooooString";
s
.isEmpty(); //ok
s.isEmpty();
foo(i,
s); //ok
}
public static void foo(int i, String s)
{
}
}
class badCaseComma {
public void goodCase(int... aFoo)
{
int i = 0;
String s = "ffffooooString";
boolean b = s.
isEmpty();
foo(i
,s); //warn
int[] j;
}
public static String foo(int i, String s)
{
String maxLength = "123";
int truncationLength = 1;
CharSequence seq = null;
Object truncationIndicator = null;
return new StringBuilder(maxLength )
.append(seq, 0, truncationLength )
.append(truncationIndicator)
.toString();
}
}

View File

@ -1,63 +0,0 @@
package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
import java.util.Vector;
/** Test input for MethodDefPadCheck */
public class InputMethodParamPad
{
public InputMethodParamPad()
{
super();
}
public InputMethodParamPad (int aParam) // warn
{
super (); // warn
}
public void method()
{
}
public void method (int aParam) // warn
{
}
public void
method(double aParam)
{
// invoke constructor
InputMethodParamPad pad = new InputMethodParamPad();
pad = new InputMethodParamPad (); // warn
pad = new
InputMethodParamPad();
// call method
method();
method (); // warn
}
public void dottedCalls()
{
this.method();
this.method (); // warn
this.
method();
InputMethodParamPad p = new InputMethodParamPad();
p.method();
p.method (); // warn
p.
method();
java.lang.Integer.parseInt("0");
java.lang.Integer.parseInt ("0"); // warn
java.lang.Integer.
parseInt("0");
}
public void newArray()
{
int[] a = new int[]{0, 1};
java.util.Vector<String> v = new java.util.Vector<String>();
java.util.Vector<String> v1 = new Vector<String>();
}
}

View File

@ -1,134 +0,0 @@
package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
public class InputParenPad
{
class ParenPadNoSpace {
ParenPadNoSpace() {
this(0);
}
ParenPadNoSpace(int i) {
super();
}
@SuppressWarnings("")
void method(boolean status) {
try (Writer writer = new StringWriter()) {
do {
writer.append("a");
} while (status);
} catch (IOException e) {
while (status) {
for (int i = 0; i < (long) (2 * (4 / 2)); i++) {
if (i > 2) {
synchronized (this) {
switch (i) {
case 3:
case (4):
case 5:
break;
}
}
}
}
}
}
}
}
class ParenPadSpaceLeft {
ParenPadSpaceLeft( ) { // warning
this( 0); // warning
}
ParenPadSpaceLeft( int i) { // warning
super( ); // warning
}
@SuppressWarnings( "") // warning
void method( boolean status) { // warning
try ( Writer writer = new StringWriter( )) { // warning
do {
writer.append("a");
} while ( status); // warning
} catch ( IOException e) { // warning
while ( status) { // warning
for ( int i = 0; i < ( long) ( 2 * ( 4 / 2)); i++) { // warning
if ( i > 2) { // warning
synchronized ( this) { // warning
switch ( i) { // warning
case 3:
case ( 4): // warning
case 5:
break;
}
}
}
}
}
}
}
}
class ParenPadSpaceRight {
ParenPadSpaceRight( ) { // warning
this(0 ); // warning
}
ParenPadSpaceRight(int i ) { // warning
super( ); // warning
}
@SuppressWarnings("" ) // warning
void method(boolean status ) { // warning
try (Writer writer = new StringWriter( ) ) { // warning
do {
writer.append("a" ); // warning
} while (status ); // warning
} catch (IOException e ) { // warning
while (status ) { // warning
for (int i = 0; i < (long ) (2 * (4 / 2 ) ); i++ ) { // warning
if (i > 2 ) { // warning
synchronized (this ) { // warning
switch (i ) { // warning
case 3:
case (4 ): // warning
case 5:
break;
}
}
}
}
}
}
}
}
String foo() {
return ( (Object // warning
) bar( ( 1 > 2 ) ? // warning
( ( 3 < 4 )? false : true ) : // warning
( ( 1 == 1 ) ? false : true) ) ).toString(); // warning
}
@MyAnnotation
public boolean bar(boolean a) {
assert ( true ); // warning
return true;
}
boolean fooo = this.bar(( true && false ) && true); // warning
}
@interface MyAnnotation {
String someField( ) default "Hello world"; // warning
}
enum MyEnum {
SOME_CONSTANT( ) { // warning
int i = (int) (2 * (4 / 2)
);
};
}

View File

@ -236,24 +236,3 @@ class SpecialCasesInForLoop
return null; return null;
} }
} }
/**
* Operators mentioned in Google Coding Standards 2016-07-12
*/
class NewGoogleOperators
{
NewGoogleOperators()
{
Runnable l;
l = ()-> { }; //warn
l = () ->{ }; //warn
l = () -> { };
java.util.Arrays.sort(null, String :: compareToIgnoreCase);
java.util.Arrays.sort(null, String::compareToIgnoreCase);
new Object().toString();
new Object() . toString();
}
}

View File

@ -8,7 +8,7 @@ class myFoo
private void foo() private void foo()
{ {
int i = 0; int i = 0;
String[][] x = { {"foo"} }; String[][] x = {{"foo"}};
for (int first = 0; first < 5; first++) {} //ok for (int first = 0; first < 5; first++) {} //ok
int j = 0; int j = 0;
while (j == 1) {} //ok while (j == 1) {} //ok

View File

@ -1,7 +1,7 @@
package com.google.checkstyle.test.chapter4formatting.rule485annotations; package com.google.checkstyle.test.chapter4formatting.rule485annotations;
@MyAnnotation2 @MyAnnotation1 //warn @MyAnnotation2 @MyAnnotation1 //warn
class InputAnnotationLocation class InputCorrectAnnotationIndentation
{ {
@MyAnnotation2 @MyAnnotation1 @MyAnnotation2 @MyAnnotation1
@ -18,7 +18,7 @@ class InputAnnotationLocation
@MyAnnotation2 @MyAnnotation2
@MyAnnotation1 //warn @MyAnnotation1 //warn
public InputAnnotationLocation() {} public InputCorrectAnnotationIndentation() {}
@MyAnnotationWithParam("foo") @MyAnnotationWithParam("foo")
@MyAnnotation2 void foo1() {} @MyAnnotation2 void foo1() {}

Some files were not shown because too many files have changed in this diff Show More