Coder Social home page Coder Social logo

chesire / lintrules Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 510 KB

Add extra linting rules to Android projects

License: Apache License 2.0

Kotlin 98.82% Ruby 1.08% Shell 0.10%
lint linting-rules lint-rules gradle gradle-linter android-lint-rule lintrules hacktoberfest android-library android

lintrules's Introduction

LintRules

Extra lint rules to add to your project.

Android CI

Installation

Add the following line to your modules build.gradle

implementation 'com.github.chesire:lintrules:{version}'

Rules Added

lint-gradle

  • [DuplicateDependency] - Highlights when the same dependency has been used multiple times within the same Gradle file.
  • [LexicographicDependencies] - Highlights when dependencies within a Gradle file are not ordered lexicographically.
  • [MultipleNewline] - Highlights when multiple blank lines are detected in a row.
  • [MultipleSpaces] - Highlights when multiple spaces are detected in a row.

lint-xml

  • [ColorCasing] - Highlights when a color has been defined, but is not all uppercased.
  • [MultipleNewline] - Highlights when multiple blank lines are detected in a row.
  • [MultipleSpaces] - Highlights when multiple spaces are detected in a row.
  • [UnexpectedAttribute] - Highlights when an attribute has been used in a layout file, but it is not expected on that element.

License

Apache 2.0 - See LICENSE for more information.

lintrules's People

Watchers

 avatar  avatar

lintrules's Issues

Add warning for using ' as opposed to " in gradle files

To make the transition to Kotlin gradle files later on, flag up using ' instead of ". " should be perfectly valid throughout the Gradle files.

Might need some thoughts on how to handle methods though, as this would only really work for android and dependencies blocks.

Remove the Lexicographic Gradle dependency exclusion

There is currently an exclusion on the Kotlin version dependency, this can be removed now as it is no longer required to be set in the Gradle file, so if its still kept around it should be kept lexicographically.

Lexicographic dependencies has issue with nested modules

If modules are nested multiple times, it can flag up warnings where there aren't any

    implementation project(path: ":libraries:kitsu")
    implementation project(path: ":libraries:kitsu:trending")
    implementation project(path: ":libraries:library")
    implementation project(path: ":libraries:server")
    implementation project(path: ":libraries:server:trending")

in this example, implementation project(path: ":libraries:library") is flagged up as being in the wrong order, but it isn't.

Add lint rule for double new line

Gradle files should contain a single new line, a double new line should raise a lint warning.

dependencies {
  implementation...

  implementation...
}

should be valid, while

dependencies {
  implementation...


  implementation...
}

should raise a lint warning

Lexicographic ordering can seem a bit off

When using the Lexicographic ordering lint rule, since it is completely based on lexicographic ordering it takes into account : and . characters, causing an odd order when having multiple libraries from the same person.

ex:

 implementation 'com.chesire.lintrules:lint-gradle:1.1.0'
 implementation 'com.chesire.lintrules:lint-xml:1.1.0'
 implementation 'com.chesire:lifecyklelog:2.1.0'

is valid, whereas

 implementation 'com.chesire:lifecyklelog:2.1.0'
 implementation 'com.chesire.lintrules:lint-gradle:1.1.0'
 implementation 'com.chesire.lintrules:lint-xml:1.1.0'

should be valid instead.

Paths with multiple sections are flagged as duplicated

Adding other projects to the dependencies list flags up the duplicate issue even when they aren't, if they are added using the below syntax.

    implementation project(path: ":libraries:database")
    implementation project(path: ":libraries:server")

The whole line likely isn't being checked for duplicate dependencies.

Flag up usage of Assert

Instead of using Assert.assertFalse etc, the methods should be static imported into the file so they can be read as just assertFalse etc.

Rule could be named something like [AssertUsage].

Duplicate dependencies can fire across files

If lintOptions.checkDependencies true is set then all of the files are checked in one sweep, this causes it to flag up a duplicate dependency for the files multiple times.
Might be a way to check the file type when running the linting rules to ensure that we only do it in the same file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.