Commit 5b97a1c8 authored by aurimas@google.com's avatar aurimas@google.com

Add and start using Checkstyle 5.7

Start including Checkstyle 5.7 binary to use for Java style presubmit
checks.

BUG=318404
NOTRY=true
R=brettw@chromium.org, yfriedman@chromium.org

Review URL: https://codereview.chromium.org/451313002

Cr-Commit-Position: refs/heads/master@{#289117}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289117 0039d316-1c4b-4281-b951-d872f2087c98
parent e3c6b3ed
...@@ -42,7 +42,7 @@ sudo apt-get -f install ...@@ -42,7 +42,7 @@ sudo apt-get -f install
# be installed manually on late-model versions. # be installed manually on late-model versions.
# common # common
sudo apt-get -y install checkstyle lighttpd python-pexpect xvfb x11-utils sudo apt-get -y install lighttpd python-pexpect xvfb x11-utils
# Few binaries in the Android SDK require 32-bit libraries on the host. # Few binaries in the Android SDK require 32-bit libraries on the host.
sudo apt-get -y install lib32z1 g++-multilib sudo apt-get -y install lib32z1 g++-multilib
......
This diff is collapsed.
This diff is collapsed.
aurimas@chromium.org
newt@chromium.org
Name: Checkstyle is a development tool to help programmers write Java code that
adheres to a coding standard.
Short Name: checkstyle
URL: http://checkstyle.sourceforge.net/
Version: 5.7
License: LGPL 2.1
License File: LICENSE
Security Critical: no
Description:
Checkstyle is used to validate Java code style on Chromium PRESUBMIT step.
Local Modifications:
- Removed contrib/ and site/ directories that contained examples of how to write
new checkstyle modules.
- Removed xml files used for Eclipse setup when building new checkstyle modules.
- checkstyle_checks.xml
- import-control.xml
- supressions.xml
- Removed jars already included in checkstyle-5.7-all.jar
- antlr-2.7.7.jar
- checkstyle-5.7.jar
- commons-beanutils-core-1.8.3.jar
- commons-cli-1.2.jar
- commons-logging-1.1.1.jar
- guava-jdk5-14.0.1.jar
SOFTWARE RIGHTS
$Id: RIGHTS.antlr,v 1.1 2001-06-22 13:11:01 oburn Exp $
ANTLR 1989-2000 Developed by jGuru.com (MageLang Institute),
http://www.ANTLR.org and http://www.jGuru.com
We reserve no legal rights to the ANTLR--it is fully in the
public domain. An individual or company may do whatever
they wish with source code distributed with ANTLR or the
code generated by ANTLR, including the incorporation of
ANTLR, or its output, into commerical software.
We encourage users to develop software with ANTLR. However,
we do ask that credit is given to us for developing
ANTLR. By "credit", we mean that if you use ANTLR or
incorporate any source code into one of your programs
(commercial product, research project, or otherwise) that
you acknowledge this fact somewhere in the documentation,
research report, etc... If you like ANTLR and have
developed a nice tool with the output, please mention that
you developed it using ANTLR. In addition, we ask that the
headers remain intact in our source code. As long as these
guidelines are kept, we expect to continue enhancing this
system and expect to make other tools available as they are
completed.
The primary ANTLR guy:
Terence Parr
http://www.jGuru.com
parrt@jguru.com
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2014 Oliver Burn
//
// 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
////////////////////////////////////////////////////////////////////////////////
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->
<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<!-- Checks that a package-info.java file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<module name="JavadocPackage"/>
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter"/>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->
<module name="TreeWalker">
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/>
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength"/>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="AvoidInlineConditionals"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
</module>
</module>
...@@ -24,7 +24,10 @@ def RunCheckstyle(input_api, output_api, style_file): ...@@ -24,7 +24,10 @@ def RunCheckstyle(input_api, output_api, style_file):
checkstyle_env = os.environ.copy() checkstyle_env = os.environ.copy()
checkstyle_env['JAVA_CMD'] = 'java' checkstyle_env['JAVA_CMD'] = 'java'
try: try:
check = subprocess.Popen(['checkstyle', '-c', style_file] + java_files, check = subprocess.Popen(['java', '-cp',
'third_party/checkstyle/checkstyle-5.7-all.jar',
'com.puppycrawl.tools.checkstyle.Main', '-c',
style_file] + java_files,
stdout=subprocess.PIPE, env=checkstyle_env) stdout=subprocess.PIPE, env=checkstyle_env)
stdout, _ = check.communicate() stdout, _ = check.communicate()
if check.returncode == 0: if check.returncode == 0:
...@@ -56,4 +59,4 @@ def RunCheckstyle(input_api, output_api, style_file): ...@@ -56,4 +59,4 @@ def RunCheckstyle(input_api, output_api, style_file):
full_path, end = error.split(':', 1) full_path, end = error.split(':', 1)
rel_path = os.path.relpath(full_path, local_path) rel_path = os.path.relpath(full_path, local_path)
output.append(' %s:%s' % (rel_path, end)) output.append(' %s:%s' % (rel_path, end))
return [output_api.PresubmitPromptWarning('\n'.join(output))] return [output_api.PresubmitPromptWarning('\n'.join(output))]
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment