Skip to content

Latest commit

 

History

History
55 lines (31 loc) · 2.55 KB

coding-style.md

File metadata and controls

55 lines (31 loc) · 2.55 KB

Coding Style

Our code style guidelines are based on the Android Code Style Guidelines for Contributors. We only changed a few rules:

  • Line length is 120 characters
  • FIXME must not be committed in the repository use TODO instead. FIXME can be used in your own local repository only.

On top of the Android linter rules (best run for this project using ./gradlew lintWordPressVanillaRelease), we use two linters: Checkstyle (for Java and some language-independent custom project rules), and detekt (for Kotlin).

Checkstyle

You can run checkstyle via a gradle command:

$ ./gradlew checkstyle

It generates an HTML report in WordPress/build/reports/checkstyle/checkstyle.html.

You can also view errors and warnings in realtime with the Checkstyle plugin. When importing the project into Android Studio, Checkstyle should be set up automatically. If it is not, follow the steps below.

You can install the CheckStyle-IDEA plugin in Android Studio here:

Android Studio > Preferences... > Plugins > CheckStyle-IDEA

Once installed, you can configure the plugin here:

Android Studio > Preferences... > Tools > Checkstyle

From there, add and enable the custom configuration file, located at config/checkstyle.xml.

Detekt

You can run detekt via a gradle command:

$ ./gradlew detekt

It generates an HTML report in WordPress/build/reports/detekt/detekt.html.

You can also view errors and warnings in realtime with the Detekt plugin.

You can install the detekt plugin in Android Studio here:

Android Studio > Preferences... > Plugins > detekt

Once installed, you can configure the plugin here:

Android Studio > Preferences... > Tools > Detekt

From there, add and enable the custom configuration file, located at config/detekt/detekt.yml.

If you want to use the AutoCorrect feature of the plugin, make sure that the option Enable formatting (ktlint) rules is enabled in the above settings, then you will be able to reformat any file according to detekt's rules using the refactor menu AutoCorrect by Detekt Rules.

Please don’t add a new suppression line to the baseline.xml. Consider fixing the issue or suppressing locally if it’s necessary.