metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Leet <justinjl...@gmail.com>
Subject Java Code style is now Google Java Style Guide
Date Tue, 01 Aug 2017 02:23:10 GMT
Hi all,

Following the merge of METRON-746
<https://issues.apache.org/jira/browse/METRON-746> in
https://github.com/apache/metron/pull/577, our code style is to follow
the Google
Java Style Guide <https://google.github.io/styleguide/javaguide.html>,
where previously it was a two-space indented variant of the Sun standards.
Please take a look over the style guide, but it should mostly conform to
what everyone is used to other than some minor things. This does not
include any automated enforcement of code formatting, it's still the
contributor's responsibility (and instructions for IntelliJ IDEA warnings
and code formatting setup are included at the bottom).

Right now, there is a ticket for reformatting our existing code, but
specifics haven't been worked out (See: METRON-747
<https://issues.apache.org/jira/browse/METRON-747>).  Please follow the
existing practices of not reformatting files for unrelated changes and
following the general formatting of a noncomplying files.

The wiki has not been updated yet (I'll need permissions, if someone wants
to work with me to update it).  Both the updated style and a set of IDE
instructions will be added.  I'll follow up this email with a link when
completed, but a wall of text setup is included both here and on the PR in
the meantime

Here's how to get warnings and formatting in IntelliJ IDEA.  Eclipse
refused to show any warnings or errors with our project, so if someone is
successfully using Eclipse (or wants to), I'm happy to help out and update
the instructions. The PR's formatting might be more readable, so feel free
to refer to it.

The steps to get warnings in the IDE are:

   - Install the plugin (Available in IntelliJ's directly)
   - Go into Settings -> Other Settings -> Checkstyle
   - Change "Checkstyle version" to 8.0.
   - Apply. Otherwise the new file won't match the version and an error
   will be thrown.
   - Add a new Checkstyle file
      - Use the checkstyle.xml file included in the root directory of the
      project. This file is identical to google_checks.xml
      <https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml>,
      but we may choose to change it in the future.
      - 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

New warnings should show up in Java files, such as whitespace issues, etc.
See Google's Java Style Checkstyle Coverage
<http://checkstyle.sourceforge.net/google_style.html> for what exactly what
Checkstyle can look for and what needs an actual human set of eyes.

For code formatting:

There are two options for IDE code formatting. One is to import the
checkstyle.xml file from the project root. The other is to import Google's
IntelliJ editor settings for coverage. In practice, Google's direct
IntelliJ settings seem to handle autoformatting better.

Follow the instructions for setting up formatting 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 by choosing the CheckStyle
Configuration when doing Import Scheme.

At this point, running the code formatter should take care of most
formatting issues.  In my experience several issues, such as commas being
at the start of the line, will be not automatically resolved (although the
IDE will give a warning).

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message