Skip to content

An exploration in custom rule creation for the WartRemover Scala linter

Notifications You must be signed in to change notification settings

jultty/wart-AnyOps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wart-AnyOps

Linting rules to prevent operations between numerical and non-numerical "primitives".

Addresses weirdness such as:

3 + 'a'     // 100
'a' + 'a'   // 194
'3' + 0     // 99
'a' == 97   // true

While I wouldn't like to get 3 from '3' + 0 (a char added to an integer) something as unpredictable as 99 is not ideal either.

In the example above, Scala performs implicit conversions through which the chars will be converted to their corresponding values in the ASCII table.

Operations with + and strings are already covered by the built-in wart StringPlusAny, upon which implementation this repo is largely based.

Caveats

This wart will not work if your project uses Scala 2 or does cross-compiling to Scala 2.

Usage

This project is built using sbt. Provided you have this repository cloned and a Scala environment configured, you can compile code with sbt compile, run it with sbt run, and launch a REPL with sbt console.

About

An exploration in custom rule creation for the WartRemover Scala linter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages