Skip to content

jean-andre-gauthier/scalasca

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scalasca

A static code analysis plugin for the Scala compiler.

Compiling

Use sbt and package to compile the plugin.

Testing

In order to run the unit tests, use SBT's testOnly. Standalone tests can be run using src/standaloneTest. As a first example, you can run ScalaSCA on ScalaSCA's source itself, using the src/autoCheck script.

Run

Once the plugin has been compiled, it can be used as an additional phase for the compiler: scalac -Xplugin:target/scala-XXX/scalasca_XXX-0.1.jar, where XXX stands for the current scala version.

Summary

ScalaSCA has four warning levels, that are displayed in their respective colours, if your terminal supports them:

  • Notice (white): for rules of any kind, that do not check the "correctness" of the code. General static analyses (e.g. constant propagation) typically fall into this category
  • Warning (yellow): generally used when a rule discovered a potential bug (medium probability)
  • Severe warning (dark yellow): used when a rule discovered a potential bug (high probability)
  • Fatal (red): used when a rule discovered a piece of code that will crash at runtime, if executed
Rule Error Code Description Category
ASS_USELESSASSIGNMENT (Re-)assignment to val/var has no effect Bad Practice
MEM_MISSING_RESOURCE_CLOSING Resource not freed after usage Bad Practice
CLS_PUBLIC_MUTABLE_FIELDS Public vars in classes/objects/traits Bad Practice
MET_DOUBLE_TRIPLE_EQUALS (Akka.Actor) Use of == vs === Dodgy Code
ARI_DIV_BY_ZERO Divison by 0 Fatal
GEN_UNUSED_CODE_REMOVAL Removes unused code General
GEN_BLOCK_CONST_PROP Propagates constant values General

Improvements

  • BlockConstantPropagation casts to String and Int in Constant val built from other constants. Any clean quasiquotish solution for this (not being able to be lifted to Any)?
  • BlockConstantPropagation does not consider arbitrary methods

About

A static code analysis plugin for the Scala compiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published