Mobile/Fennec/Android/Static analysis/checkstyle-idea: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Replace link to checkstyle.xml with link to raw version (previous link goes to html mxr page, which the plugin can't handle))
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:


== Installation ==
== Installation ==
# Open the preferences
* Open the preferences
# Find "Plugins" in the preferences
* Find "Plugins" in the preferences
# Click "Browse repositories"
* Click "Browse repositories"
# Search for "checkstyle".
* Search for "checkstyle".
# Select CheckStyle-IDEA
* Select CheckStyle-IDEA
# Click "Install plugin" on the right & confirm
* Click "Install plugin" on the right & confirm
# Click restart Android Studio
* Click restart Android Studio


=== Adding the config file ===
=== Adding the config file ===
# Click the "+" in the Configuration File box
* Open the preferences
# Open the preferences
* Go to (or search for) "Checkstyle" menu item (it's under "Other Settings")
# Go to (or search for) "Checkstyle" menu item (it's under "Other Settings")
* Click the plus at the bottom of the "Configuration file" box
TODO: can we do this by code?
* Add a description (e.g. "mozilla")
http://mxr.mozilla.org/mozilla-central/source/mobile/android/app/checkstyle.xml
* Add the path to the checkstyle configuration: <pre>http://mxr.mozilla.org/mozilla-central/source/mobile/android/app/checkstyle.xml?raw=1</pre>
* Accept
* Click the "Active" checkbox next to the new configuration
* Hit "OK" to close the preferences

Latest revision as of 16:41, 2 May 2016

You can run checkstyle via the checkstyle-idea plugin within Android Studio or Intellij. It will highlight violations in red, e.g. package statements should not span more than one line:

Example of checkstyle-idea failure

Installation

  • Open the preferences
  • Find "Plugins" in the preferences
  • Click "Browse repositories"
  • Search for "checkstyle".
  • Select CheckStyle-IDEA
  • Click "Install plugin" on the right & confirm
  • Click restart Android Studio

Adding the config file

  • Open the preferences
  • Go to (or search for) "Checkstyle" menu item (it's under "Other Settings")
  • Click the plus at the bottom of the "Configuration file" box
  • Add a description (e.g. "mozilla")
  • Add the path to the checkstyle configuration:
    http://mxr.mozilla.org/mozilla-central/source/mobile/android/app/checkstyle.xml?raw=1
  • Accept
  • Click the "Active" checkbox next to the new configuration
  • Hit "OK" to close the preferences