Commit graph

127 commits

Author SHA1 Message Date
Vitalii Elenhaupt
04c7300964
Handle type declarations in scopes
closes #66
2018-06-23 08:48:13 +03:00
Vitalii Elenhaupt
c12b4f1aa5 Shadowed argument 2018-05-29 09:47:32 +03:00
Vitalii Elenhaupt
15bb8f5331 Detect shadowing outer local vars 2018-05-29 09:47:20 +03:00
Vitalii Elenhaupt
bf907ee98b
Rework variable references detection in macro 2018-05-12 20:08:24 +03:00
Vitalii Elenhaupt
efe67212b0
Support of Crystal::UnitializedVar 2018-05-12 18:29:31 +03:00
Vitalii Elenhaupt
415432713a
Prevent false positiveness cause by macro literals
https://github.com/crystal-lang/crystal/pull/6055#issuecomment-386376227
2018-05-12 17:37:54 +03:00
V. Elenhaupt
c2aa526e21
Unused argument rule (#52)
* Unused argument rule

* IgnoreDefs, IgnoreBlocks, IgnoreProcs parameters

* Implicit reference by super keyworkd

* Handle macro arguments
2018-05-08 22:00:17 +03:00
Vitalii Elenhaupt
cc71511080
Use Var#special_var? to check if var is special 2018-05-04 16:25:44 +03:00
V. Elenhaupt
6475c2bb25
Variable scope & useless assignments (#41)
* AST::Visitor -> AST::NodeVisitor

* Scope & ScopeVisitor

* Useless assignment rule

* Instance vars and useless assignments

* Multiple assigns one by one

* Support outer scope

* Variable used in the useless assignment

* Support OpAssign & MultiAssign

* Captured by block

* Variable, Assignment, Reference & Refactoring

* Variable has references, Assignment can be referenced

* Branch entity

* Handle useless assignments in branches

* Handle assignments in a loop

* Handle branch equality

* Handle special var `$?` assignment

* Improve captured by block stuff

* Avoid assignments in property definitions

(UselessAssign rule reports an warning)

* Support MacroIf and MacroFor branches

* Handle assignments with shadowed vars in inner scopes

* Add method arguments as scope variables

* Handle case if branch is blank

* Top level scope

* Handle case when branch is nop?
2018-05-03 18:57:47 +03:00
Vitalii Elenhaupt
96c1af4e35
New rule: useless condition in when
thanks to @hugoabonizio for suggesstion
2017-12-02 21:55:50 +02:00
Hugo Abonizio
b023ae0baa Disallows while true (#22)
* Disallows `while true`

* Add syntax highlighting in documentation

* Replace `while true` occurrencies

* Add WhileTrue rule to config sample
2017-11-27 15:35:15 +02:00
Vitalii Elenhaupt
1839ef2ab5
New rule: hash duplicated key 2017-11-18 00:51:16 +02:00
Vitalii Elenhaupt
b3a9ff2fa0
Mark begin; end as empty expression 2017-11-17 18:32:40 +02:00
Vitalii Elenhaupt
fb398b5056
New rule: redundant begin 2017-11-17 18:15:11 +02:00
Vitalii Elenhaupt
e5081fa970
New rule: empty ensure 2017-11-16 16:31:32 +02:00
Vitalii Elenhaupt
57b1095c5f
Document entities 2017-11-15 23:37:16 +02:00
Vitalii Elenhaupt
80e2ab4f55
Ameba::Rule -> Ameba::Rule::Base 2017-11-08 00:02:32 +02:00
Vitalii Elenhaupt
9036a7ca71
New rule: empty assignment 2017-11-07 20:54:28 +02:00
Vitalii Elenhaupt
a9421ee79b
AST node source code 2017-11-07 13:28:33 +02:00
V. Elenhaupt
adfe654733
Performance improvements (#15)
* Performance improvements

Two main changes:

1. Cache parsed AST in a Source. So Parser will parse content only once.
2. Use one unified visitor with multiple callbacks instead of multiple
visitors to traverse AST.

This improves performance significantly, for example running it on
Crystal repository takes ~1 second, which 6 times faster than before.

* Change readme example
2017-11-06 20:54:58 +02:00
V. Elenhaupt
374956f3dd
Fix travis build & new rule: constant names (#14) 2017-11-05 22:08:01 +02:00
Vitalii Elenhaupt
8440747353
New rule: variable names 2017-11-04 23:13:38 +02:00
Vitalii Elenhaupt
20fd53682f
New rule: type names 2017-11-04 18:57:35 +02:00
V. Elenhaupt
2f9ba27811
Large numbers rule + tokenizer (#10) 2017-11-04 16:43:40 +02:00
Vitalii Elenhaupt
0ca990dd5c
New rule: predicate name 2017-11-01 15:20:04 +02:00
Vitalii Elenhaupt
64ccc7448c
New rule: literal in the interpolation 2017-11-01 14:18:28 +02:00
Vitalii Elenhaupt
6a81a648e3
AST Util 2017-11-01 13:13:44 +02:00