You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metron.apache.org by justinleet <gi...@git.apache.org> on 2017/05/09 22:54:17 UTC

[GitHub] incubator-metron pull request #577: METRON-746: Build Custom Checkstyle and ...

GitHub user justinleet opened a pull request:

    https://github.com/apache/incubator-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/incubator-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 5e4cc365836f70f0a4951d78c7def5248da56d91
Author: justinjleet <ju...@gmail.com>
Date:   2017-05-03T12:09:15Z

    initial checkstyle

commit 6a44efc51591f768127b123ec71086bdcc6b7119
Author: justinjleet <ju...@gmail.com>
Date:   2017-05-08T13:35:17Z

    checkstyle playing around

commit 7f18912f8a031dc2ea56def1c62f514466af930d
Author: justinjleet <ju...@gmail.com>
Date:   2017-05-08T16:07:26Z

    deleting checkstyles and moving to Google's

commit 7d91533183eb8a57fc2370a8449fe0547d378598
Author: justinjleet <ju...@gmail.com>
Date:   2017-05-09T21:10:49Z

    fixing

commit 744529fb6269e7d9585b344c6669ef7000ae978a
Author: justinjleet <ju...@gmail.com>
Date:   2017-05-09T22:00:05Z

    Don't set properties to their defaults

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---