Commit graph

167 commits

Author SHA1 Message Date
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
d307f01bfa
Add a space delimiter to duplicated hash keys 2018-04-13 20:10:21 +03:00
Hugo Abonizio
d6c6af883d Ignores PredicateName if alternative isn't valid (e.g. is_404?) 2018-04-12 19:20:41 +03:00
Vitalii Elenhaupt
9e2ab9c002
Show hash duplicated keys in error message
closes #45
2018-04-12 19:18:33 +03:00
Vitalii Elenhaupt
2f837375ec New rule: rand zero 2018-03-08 18:59:20 +02:00
Vitalii Elenhaupt
eda5960b0f Check for unneeded directives when all other rules are done 2018-02-02 22:17:04 +02:00
Vitalii Elenhaupt
6fb483a2dd Prevent disabling of UnneededDisableDirective rule 2018-02-02 22:17:04 +02:00
Vitalii Elenhaupt
8075c39aa9 Unneeded disable directive 2018-02-02 22:17:04 +02:00
Vitalii Elenhaupt
2382657e15
Add rule's name to flycheck formatter 2018-01-31 13:30:59 +02:00
Vitalii Elenhaupt
69cff77970 Add DisabledFormatter to trace disabled lines 2018-01-30 16:09:00 +02:00
Vitalii Elenhaupt
9f85b16e09 Add inline directives parsing and disabling 2018-01-30 16:09:00 +02:00
Vitalii Elenhaupt
55b66e7975 Use more natural way to define error with custom loc 2018-01-30 16:09:00 +02:00
Vitalii Elenhaupt
1d436fbb94
Allow to configure formatter via configuration file
closes #20
2018-01-25 16:53:08 +02:00
Vitalii Elenhaupt
4c85ad7c75 Syntax rule running priorities 2018-01-25 12:37:25 +02:00
Vitalii Elenhaupt
c9db63bf34 Syntax rule 2018-01-25 12:37:25 +02:00
Vitalii Elenhaupt
7e8703dda0 Crystal 0.24.1 support 2017-12-26 18:21:21 +02:00
Vitalii Elenhaupt
eca0d28692
Excluded relative path path 2017-12-18 13:06:19 +02:00
Vitalii Elenhaupt
b515faff87 Add cmd specs 2017-12-11 11:19:56 +02:00
Vitalii Elenhaupt
e1fa8677b0 Add flycheck formatter
refs #26
2017-12-11 11:19:56 +02:00
V. Elenhaupt
f12a224dad
New rule: shadowed exception (#25) 2017-12-06 16:59:10 +02:00
Vitalii Elenhaupt
96c1af4e35
New rule: useless condition in when
thanks to @hugoabonizio for suggesstion
2017-12-02 21:55:50 +02:00
Vitalii Elenhaupt
8cbdd0de4d Remove temp config, adjust Readme 2017-12-01 19:01:25 +02:00
Vitalii Elenhaupt
8bf5066d6a Add Excluded property to the rule 2017-12-01 19:01:25 +02:00
Vitalii Elenhaupt
a1854c0aa3 TODO formatter 2017-12-01 19:01:25 +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
21abce63bd
Report only wrong predicate names 2017-11-23 19:58:59 +02:00
Vitalii Elenhaupt
dceafd26e5
Except & only cli flags 2017-11-23 19:49:45 +02:00
Vitalii Elenhaupt
f4f401d56f
Make config loading more flexible 2017-11-23 10:41:22 +02:00
Vitalii Elenhaupt
0520774930
New rule: duplicated when 2017-11-18 18:39:45 +02:00
Vitalii Elenhaupt
1839ef2ab5
New rule: hash duplicated key 2017-11-18 00:51:16 +02:00
Vitalii Elenhaupt
791bfdabb8
New rule: percent arrays 2017-11-17 23:56:52 +02:00
Vitalii Elenhaupt
3c9df13beb
New option: LargeNumbers#int_min_digits (default: 5) 2017-11-17 19:07:39 +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
06855816d7
Document configuration properties & specs 2017-11-14 10:28:26 +02:00
Vitalii Elenhaupt
80e2ab4f55
Ameba::Rule -> Ameba::Rule::Base 2017-11-08 00:02:32 +02:00
Vitalii Elenhaupt
e718c90f16
Source#content -> Source#code, Source::Error#pos -> Source::Error#location 2017-11-07 23:02:38 +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
Vitalii Elenhaupt
f878ac430f
Refactor formatters 2017-11-06 10:41:03 +02:00
Vitalii Elenhaupt
1a3bb3629e
Line lenght: 80 symbols 2017-11-06 08:54:59 +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
3d4c44c333
New rule: method names 2017-11-04 22:54:27 +02:00
Vitalii Elenhaupt
20fd53682f
New rule: type names 2017-11-04 18:57:35 +02:00
Vitalii Elenhaupt
e383ec17c2
Refactor tokenizer 2017-11-04 17:38:04 +02:00
V. Elenhaupt
2f9ba27811
Large numbers rule + tokenizer (#10) 2017-11-04 16:43:40 +02:00
Vitalii Elenhaupt
c9f229c3f1
Custom matcher 2017-11-01 22:05:41 +02:00
Vitalii Elenhaupt
67506fc643
New rule: negated conditions in unless 2017-11-01 21:30:30 +02:00
Vitalii Elenhaupt
0ca990dd5c
New rule: predicate name 2017-11-01 15:20:04 +02:00
Vitalii Elenhaupt
348496ab9d
New rule: debugger statement 2017-11-01 14:44:00 +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
Vitalii Elenhaupt
dcc0be892a
Load list of rules dynamically 2017-11-01 12:49:03 +02:00
Vitalii Elenhaupt
1822b2b0a2
Fix line rule failure 2017-11-01 12:23:12 +02:00
Vitalii Elenhaupt
6f5d7f0478
New rule: a literal in the condition 2017-11-01 12:22:37 +02:00
Vitalii Elenhaupt
2eef485501
AST traverse 2017-11-01 01:06:47 +02:00
Vitalii Elenhaupt
6d9f1c67ed
New rule: comparison to boolean 2017-10-31 23:30:22 +02:00
Vitalii Elenhaupt
11005930f6
New rule: UnlessElse 2017-10-31 22:24:02 +02:00
Vitalii Elenhaupt
93dd7d446f
AST parsing
closes #2
2017-10-31 20:29:30 +02:00
Vitalii Elenhaupt
b8eeac469a
New rule: trailing blank lines 2017-10-31 17:50:05 +02:00
Vitalii Elenhaupt
7d3d0902e5
New rule: trailing whitespace 2017-10-30 22:35:11 +02:00
Vitalii Elenhaupt
9bba850a9b
Docs & tests 2017-10-30 22:00:01 +02:00
Vitalii Elenhaupt
eb367c682e
Hello, Ameba 2017-10-26 19:46:58 +03:00