[ 
https://issues.apache.org/jira/browse/METRON-746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16009082#comment-16009082
 ] 

ASF GitHub Bot commented on METRON-746:
---------------------------------------

GitHub user justinleet reopened a pull request:

    https://github.com/apache/metron/pull/577

    METRON-746: Build Custom Checkstyle and IDE formatting settings

    ## Contributor Comments
    
    Pretty much just editing the POM to actually set up Checkstyle with the 
Google Code Style, per the dev thread.
    
    See [Google Java Style 
Guide](https://google.github.io/styleguide/javaguide.html)
    
    Note that the Checkstyle version is set to 7.7.  I've tested it with the 
plugin version and had no issues at all, but if anyone is concerned, we can 
lower it to either the default or another version.
    
    ### IntelliJ warnings
    To pull into IntelliJ, please see 
https://github.com/jshiell/checkstyle-idea#configuration
    Essentially the instructions are to:
    
    -  Install the plugin (Available in IntelliJ's directly)
    - Go into Settings -> Other Settings -> Checkstyle
    - Change "Checkstyle version" to 7.7.
    - Apply.  Otherwise the new file won't match the version and an error will 
be thrown.
    - Add a new Checkstyle file
      - This can either be a local file or a remote one (remote will attempt to 
update periodically, so if you don't want to repeatedly connect to the URL, 
download the file somewhere and load it in).  Either works. For 7.7, use 
[google_checks.xml](https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml)
      - If you have errors, you most likely need to make sure you're set to the 
right version and have applied it.
    - Select the checkbox for the new style
    - Apply
    
    To ensure it's setup properly, open a file, e.g. 
`metron-platform/metron-common/src/main/java/org/apache/metron/common/dsl/functions/StringFunctions.java`
    
    New warnings should show up that are based on Checkstyle, e.g.
    ```
    Checkstyle: WhitespaceAround: 'if' is not followed by whitespace. Empty 
blocks may only be represented as {} when not part of a multi-block statement
    ```
    
    ### Code formatting
    There are two options for code formatting. One is to import the 
google_checks.xml file from above.  The other is to import Google's IntelliJ 
editor settings for coverage.  In practice, Google's direct IntelliJ settings 
seem to handle autoformatting better. The instructions are essentially the same 
for each.
    
    Google's setup is described at 
https://github.com/HPI-Information-Systems/Metanome/wiki/Installing-the-google-styleguide-settings-in-intellij-and-eclipse.
  The direct Checkstyle can be imported similarly, but choosing the CheckStyle 
Configuration when doing Import Scheme.
    
    ### Required Follow-up
    This will require updating the wiki at 
https://cwiki.apache.org/confluence/display/METRON/Development+Guidelines 
(Section 2.2).  It needs to be switched to the Google code conventions, and the 
instructions above for formatting and warnings should be pulled in.
    
    ### Testing
    I still need to spin up full-dev, but to get the checkstyle report do:
    ```
    mvn clean install -DskipTests
    mvn site site:stage-deploy site:deploy -Dmaven.javadoc.skip=true 
    ```
    Navigate to file:///tmp/metron/site/checkstyle-aggregate.html in a browser.
    You should see
    `The following document contains the results of Checkstyle 7.7 with 
google_checks.xml ruleset.` and a set of warnings. In practice, most of them 
are fixed by batch autoformatting, per discussions, which will be a followup 
task.
    
    ### Misc
    No enforcement of Checkstyle is made, and in fact, by default 
google_checks.xml sets everything to warning. The thought is that we'd need to 
pretty significantly reduce the number of warnings, and probably think through 
how we want to handle it.
    
    ## Pull Request Checklist
    
    Thank you for submitting a contribution to Apache Metron.  
    Please refer to our [Development 
Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235)
 for the complete guide to follow for contributions.  
    Please refer also to our [Build Verification 
Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview)
 for complete smoke testing guides.  
    
    
    In order to streamline the review of the contribution we ask you follow 
these guidelines and ask you to double check the following:
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? If not one needs to 
be created at [Metron 
Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
 
    - [x] Does your PR title start with METRON-XXXX where XXXX is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
    - [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?
    
    
    ### For code changes:
    - [x] Have you included steps to reproduce the behavior or problem that is 
being changed or addressed?
    - [x] Have you included steps or a guide to how the change may be verified 
and tested manually?
    - [x] Have you ensured that the full suite of tests and checks have been 
executed in the root incubating-metron folder via:
      ```
      mvn -q clean integration-test install && build_utils/verify_licenses.sh 
      ```
    
    - [ ] Have you verified the basic functionality of the build by building 
and running locally with Vagrant full-dev environment or the equivalent?
    
    ### For documentation related changes:
    - [x] Have you ensured that format looks appropriate for the output in 
which it is rendered by building and verifying the site-book? If not then run 
the following commands and the verify changes via 
`site-book/target/site/index.html`:
    
      ```
      cd site-book
      mvn site
      ```
    
    #### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.
    It is also recommended that [travis-ci](https://travis-ci.org) is set up 
for your personal repository such that your branches are built there before 
submitting a pull request.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/justinleet/incubator-metron checkstyle

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/577.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #577
    
----
commit c66b09a12da45adee00a267692ec82f411d6cd7f
Author: justinjleet <justinjl...@gmail.com>
Date:   2017-05-03T12:09:15Z

    initial checkstyle

commit 2ec01b2729372fc714b90eb08adb9e728d56c19a
Author: justinjleet <justinjl...@gmail.com>
Date:   2017-05-08T13:35:17Z

    checkstyle playing around

commit a6723d2e0a027082191a93658989528baae164fe
Author: justinjleet <justinjl...@gmail.com>
Date:   2017-05-08T16:07:26Z

    deleting checkstyles and moving to Google's

commit 23dc1f232a60f7575310d71bebd50d874b5b9bc0
Author: justinjleet <justinjl...@gmail.com>
Date:   2017-05-09T21:10:49Z

    fixing

commit 9f1acef9c5d7e4714bfe79c7d4196ec733aabb7d
Author: justinjleet <justinjl...@gmail.com>
Date:   2017-05-09T22:00:05Z

    Don't set properties to their defaults

----


> Build Custom Checkstyle and IDE formatting settings
> ---------------------------------------------------
>
>                 Key: METRON-746
>                 URL: https://issues.apache.org/jira/browse/METRON-746
>             Project: Metron
>          Issue Type: Improvement
>            Reporter: Justin Leet
>            Assignee: Justin Leet
>            Priority: Minor
>
> We need a custom checkstyle.xml based off the sun convention checkstyle.  
> Based on a discussion thread, there are a few things that need to be setup
> * Two space indents
> * Line Length longer than 80 (pretty popular in the discussion, but not 
> officially part of our code style)
> * Appropriate warn/error levels set so we don't immediately start failing 
> every build.
> * Importable IntelliJ code style at minimum, but I'd also like to see Eclipse 
> if possible to avoid forcing a given dev environment.  IntelliJ allows for 
> importing a checkstyle.xml to use as the basis.  We can export the resulting 
> formatting settings for people.
> * Ensure Travis actually runs checkstyle during our builds



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to