Commit graph

10 commits

Author SHA1 Message Date
Sijawusz Pur Rahnama
8112dddc8f Specs cleanup 2022-12-20 03:25:06 +01:00
Sijawusz Pur Rahnama
651f70f680
Update spec/ameba/ast/visitors/counting_visitor_spec.cr 2021-06-05 20:49:00 +02:00
Caspian Baska
0ea6238dc6
Count an exhaustive case's complexity as 1 2021-06-05 22:31:58 +10:00
Vitalii Elenhaupt
e9ec91654c New Rule: Lint/DuplicatedRequire
closes https://github.com/crystal-ameba/ameba/issues/176
2021-01-17 22:32:24 +02:00
Vitalii Elenhaupt
a5dd07e9e4
New rule: RedundantNext
closes #131
2020-03-24 18:06:01 +02:00
Vitalii Elenhaupt
c95ea297bd
Stop calculating cyclomatic complexity for methods which have Macro conditions (#99) 2019-03-31 20:27:20 +03:00
Hannes Käufler
e850bff60f Hk cyclomatic complexity (#92)
* Proof of concept for cyclomatic complexity

* Enable configurability of rule

* Use the same nodes to increment the complexity as rubocop

* Fix typo in test description

* Properly indent code and simplify macro

* Move metric into metrics

* Cover a violation supressed by increased threshold

* Extract visitor into its own file

* Document cyclomatic complexity rule and visitor

* Refactor specs to use a macro

* Indent code inside macro

* Replace array with tuple for string formatting.

`Tuple` is stack based, whereas `Array` is allocated on the heap increasing GC pressure.

* Fix formatting

* Enable cyclomatic complexity rule by default
2019-02-16 21:03:44 +02:00
V. Elenhaupt
0fd5890738
Extend UnreachableCode rule: handle control flow (#83) 2018-11-22 10:38:32 +02:00
Vitalii Elenhaupt
67d76116f7
Basic implementation of UnreachableCode rule 2018-11-05 21:39:27 +02: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