lewis

Additional

Language
Java
Version
N/A
Created
Jan 28, 2016
Updated
Mar 7, 2017 (Retired)
Owner
Inaka (inaka)
Contributors
Guillermo Rivero A (griveroa-inaka)
Emiliano (tenmaster)
Fernando Ramirez (ramabit)
3
Activity
Badge
Generate
Download
Source code

lewis

Rock your Android

Purpose

This is an extension for Android Lint, adding new rules:

  • RootPackage : Every .java file must be inside a custom package, not inside the root package. ERROR
  • MissingLauncher : Every application must have at least one launcher activity. WARNING
  • MoreThanOneLauncher : The application must have only one launcher activity. WARNING
  • LauncherActivityInLibrary : A library must not have a launcher activity. ERROR
  • IconInLibrary : A library must not have icons. ERROR
  • PermissionUsageInLibrary : A library must not use permissions. ERROR
  • InstanceVariableName : Every instance variable must be named beginning with 'm' and using camelCase. WARNING
  • ClassConstantName : Every class constant (static and final) must be named using UPPER_SNAKE_CASE. WARNING
  • HardcodedText : A string cannot be hardcoded inside layouts or menus. Now this is an error, not a warning. ERROR
  • LayoutIDFormat : Every id inside layouts or menus must be named using lowerCamelCase. ERROR

Exceptions to InstanceVariableName rule:

  1. The class is a model (should be inside a package called 'models').
  2. The variable is declared using @Bind or @InjectView (ButterKnife).

Getting started

Clone this repository

git clone https://github.com/inaka/lewis.git

Enter to the project

cd lewis/

Build it

./gradlew build

Install it

./gradlew install

Verify whether the issues are registered with lint

lint --show RootPackage

Go to any Android project and run lint

./gradlew lint

Note: If you can't run lint directly, you may want to include android tools PATH in your ~/.bash_profile. (i.e. PATH=$PATH:~/Library/Android/sdk/tools)

Then run source ~/.bash_profile.

How to disable an issue

Add on your build.gradle file

android {
    lintOptions {
        disable 'RootPackage','MoreThanOneLauncher'
        ...
    }
}