Commit graph

187 commits

Author SHA1 Message Date
fn ⌃ ⌥
e93dfe9cdc Convert Style/VariableNames spec 2021-11-08 14:24:11 -08:00
fn ⌃ ⌥
265bc51481 Convert Style/UnlessElse spec 2021-11-08 14:07:35 -08:00
fn ⌃ ⌥
06c0887136 Convert Style/TypeNames spec 2021-11-08 14:07:35 -08:00
fn ⌃ ⌥
e7cfe387d6 Autocorrect Stye/RedundantNext and Style/RedundantReturn 2021-11-08 14:07:35 -08:00
fn ⌃ ⌥
7b437fbd2f
Remove normalize parameter from expect_issue (#249)
* Add `normalize` parameter to `expect_correction`

* Convert Style/IsAFilter spec

* Revert "Add `normalize` parameter to `expect_correction`"

This reverts commit 4b67e4b900.

* Remove `normalize` parameter from `expect_issue`

* Require indentation if multiple issues on a single line

* Update `Style/IsAFilter` spec

* Update `ExpectIssue` documentation

* Add missing `expect_no_corrections`

* Use carets and space with issues at column 1 or 2

* Update `expect_issue` docs
2021-11-06 15:15:19 +02:00
fn ⌃ ⌥
78071722c4 Rename s to source 2021-11-01 08:55:48 -07:00
fn ⌃ ⌥
c2aa2fedb6 Return source from expect_issue 2021-10-31 22:44:48 -07:00
fn ⌃ ⌥
1d5f554e88 Apply suggestions from code review 2021-10-26 12:06:24 -07:00
fn ⌃ ⌥
573881cb8a Autocorrect Layout/TrailingBlankLines partially 2021-10-25 12:38:29 -07:00
fn ⌃ ⌥
e5fb0526e0 Autocorrect Style/LargeNumbers 2021-10-25 12:38:29 -07:00
fn ⌃ ⌥
9f0b9a709e Allow named replacements in expect_issue 2021-10-23 01:37:24 -07:00
fn ⌃ ⌥
3d432fdee8
Add expect_issue and expect_no_issues spec helpers (#245) 2021-10-22 19:54:39 +02:00
fn ⌃ ⌥
48b15b9bf8
Add Lint/AmbiguousAssignment rule (#244) 2021-10-19 11:44:41 +02:00
Sijawusz Pur Rahnama
43dea0e49d Fix typos throughout the codebase 2021-07-03 14:15:23 +02:00
Vitalii Elenhaupt
a64f48b543
ShadowingOuterLocalVar while it is not in macro
closes #224
2021-04-18 20:55:10 +03:00
Vitalii Elenhaupt
9e2d4f1856
Disable performance rules for spec files
closes #220
2021-04-18 09:39:55 +03:00
Sijawusz Pur Rahnama
2694a0c865 Remove “join” from the list of trigger methods 2021-04-12 06:22:54 +02:00
Vitalii Elenhaupt
58d7775d65
Merge branch 'master' into develop 2021-04-04 21:08:02 +03:00
Sijawusz Pur Rahnama
8d21733b10 Skip macro code in Style/IsAFilter rule 2021-04-04 11:19:45 +02:00
Stephen Dolan
04ba9cd57a
Change Style/VerboseBlock - ExcludeOperators - setting default (#218) 2021-03-24 21:16:51 +01:00
Vitalii Elenhaupt
13605afe4a
Do not report IsAFilter if there is a block with multiple args 2021-03-23 20:57:50 +02:00
Sijawusz Pur Rahnama
56110b3883 Default to exclude_multiple_line_blocks in Style/VerboseBlock rule 2021-03-03 00:31:53 +01:00
Sijawusz Pur Rahnama
8f308e73e5 Add ~ as the prefix operator 2021-03-02 12:40:46 +01:00
Sijawusz Pur Rahnama
694c41650c Remove redundant check and add a few more test cases 2021-02-05 01:23:29 +01:00
Sijawusz Pur Rahnama
a9d1b17deb Support named arguments in VerboseBlock#node_to_s 2021-02-05 01:23:29 +01:00
Sijawusz Pur Rahnama
16743a756c Add ExcludePrefixOperators option to Style/VerboseBlock rule 2021-02-04 21:59:23 +01:00
Sijawusz Pur Rahnama
eed094b928 Fix couple of edge-cases in VerboseBlock rule 2021-02-04 21:59:23 +01:00
Sijawusz Pur Rahnama
4b7f3ba6ee Add MaxLineLength option to Style/VerboseBlock rule 2021-02-04 21:59:22 +01:00
Sijawusz Pur Rahnama
0739fad670 Add Style/VerboseBlock rule 2021-02-04 21:59:22 +01:00
Sijawusz Pur Rahnama
99da6b6916 Merge remote-tracking branch 'origin/master' into master-into-develop 2021-02-03 22:45:35 +01:00
Vitalii Elenhaupt
ecad80a96b
NewRule: SpecFocus
closes #172
2021-02-03 17:10:07 +02:00
Vitalii Elenhaupt
51b0a07e81
Avoid exponential recursion while finding variable references in scopes (#203)
* Avoid exponential recursion while finding variable references in scopes

* Adjust source example in test
2021-01-31 16:40:44 +02:00
Sijawusz Pur Rahnama
fac8072ec1
Merge pull request #197 from crystal-ameba/feature/any-instead-of-empty
Add Performance/AnyInsteadOfEmpty rule
2021-01-28 10:28:30 +01:00
Sijawusz Pur Rahnama
d71091a40c Add Performance/AnyInsteadOfEmpty rule 2021-01-28 01:03:48 +01:00
Sijawusz Pur Rahnama
95d340c3ad Add Style/IsAFilter rule 2021-01-28 00:58:06 +01:00
Sijawusz Pur Rahnama
6acb8ad2eb ChainedCallsWithNoBang -> ChainedCallWithNoBang 2021-01-22 17:24:45 +01:00
Sijawusz Pur Rahnama
d3b952f58a Add Performance/ChainedCallsWithNoBang rule 2021-01-21 12:47:10 +01:00
Vitalii Elenhaupt
7aa7efd4bd Do not report if variable is assigned and referenced in MacroFor/MacroIf/MacroExpression
closes #194
2021-01-20 13:14:42 +02:00
Sijawusz Pur Rahnama
ddaa58f475
Merge pull request #192 from crystal-ameba/feature/flatten-after-map-rule
Add Performance/FlattenAfterMap rule
2021-01-19 22:16:10 +01:00
Sijawusz Pur Rahnama
23b4b4c4f0 Add Performance/FlattenAfterMap rule 2021-01-18 18:04:54 +01:00
Sijawusz Pur Rahnama
b7286dc673 Add Performance/CompactAfterMap rule 2021-01-18 18:04:12 +01:00
Sijawusz Pur Rahnama
d2fa75280f
Extend JoinAfterMap to check also calls to sum/product and rename it to MapInsteadOfBlock (#190) 2021-01-18 17:42:50 +02: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
Sijawusz Pur Rahnama
a892cd43b0 Add Performance/JoinAfterMap rule 2021-01-17 16:57:15 +01:00
Sijawusz Pur Rahnama
1a091c1f1a
Optimize rules (#185)
* Replace pointless interpolations with actual values

* Rules optimizations

* Stylistic refactors

* Remove extraneous blank lines

* Remove some instances of .not_nil! usage
2021-01-17 14:16:04 +02:00
Vitalii Elenhaupt
44290a6a5d
Handle case when compiler reports incorrect node location
fixes #168
2020-10-23 10:41:17 +03:00
Vitalii Elenhaupt
f8d57345d4
Merge branch 'develop' 2020-08-26 22:46:03 +03:00
Vitalii Elenhaupt
b5bd76dfa8
Useless Assign: ignore variables with '_' prefix
closes #164
2020-08-20 21:15:58 +03:00
Vitalii Elenhaupt
d650ca5477
Incorrectly reporting shadowingOuterLocalVar within macro included
closes #161
2020-07-15 10:18:12 +03:00
Vitalii Elenhaupt
7f501a1df5
RedundantStringCoercion: do not report to_s with named args
closes #160
2020-06-24 09:26:03 +03:00
Vladislav Trotsenko
bdeb6e3391
Feature/Layout trailing lines, final newline checkup (#152) 2020-05-05 16:52:24 +03:00
Vitalii Elenhaupt
478da94c20
Allow constants to be in PascalCase (i.e. Log, SuperConstant)
closes #148
2020-04-13 09:38:05 +03:00
Sijawusz Pur Rahnama
1a25583036
Make InlineComments::COMMENT_DIRECTIVE_REGEX more strict (#146) 2020-04-11 09:55:41 +03:00
Vitalii Elenhaupt
458c492730
Do not report shadowing outer local var is var is declared below the
shadowed var

closes #144
2020-04-10 10:44:42 +03:00
Vitalii Elenhaupt
99c65b5a28
New rule: Lint/BadDirective (#143)
* New rule: Lint/BadDirective

* Address PR feedback
2020-04-06 15:10:34 +03:00
Vitalii Elenhaupt
db6b54e63c
New rule: Style/IsANil 2020-03-29 19:45:13 +03:00
Vitalii Elenhaupt
04497feeed
Lint/LiteralInInterpolation: properly report node position 2020-03-27 19:44:04 +02:00
Vitalii Elenhaupt
59bc021e57
Do not report if Object#to_s is called without receiver 2020-03-26 23:51:54 +02:00
Vitalii Elenhaupt
ff1669ebe8
New rule: Lint/RedundantStringCoercion 2020-03-26 16:26:27 +02:00
Vitalii Elenhaupt
a6958ab455
New rule: EmptyLoop 2020-03-26 10:27:00 +02:00
Vitalii Elenhaupt
4f185db0a2
New rule: SharedVarInSpawn
closes #132
2020-03-25 17:52:20 +02:00
Vitalii Elenhaupt
0002c36fae
RedundantNext params 2020-03-24 18:27:49 +02:00
Vitalii Elenhaupt
a5dd07e9e4
New rule: RedundantNext
closes #131
2020-03-24 18:06:01 +02:00
Vitalii Elenhaupt
946ec67fae
Include binary op node to redundant return 2020-03-22 20:12:24 +02:00
Vitalii Elenhaupt
aff723b682
Incorrectly reporting shadowingOuterLocalVar within macro included
closes #129
2020-02-15 20:49:47 +02:00
Vitalii Elenhaupt
74dfa0b934
Lint/UselessAssign: ignore transformed assignemnts by the compiler
closes #127
2020-01-11 23:51:28 +02:00
Vitalii Elenhaupt
6b56c87e78
Shadowing via short instance variable syntax
closes #122
2019-11-11 15:51:09 +02:00
Vitalii Elenhaupt
fde321f7e6
New rule: RedundantWithObject (#121) 2019-11-10 09:47:30 +02:00
Vitalii Elenhaupt
b6cc454039
New rule: RedundantWithIndex (#120) 2019-11-10 09:29:17 +02:00
Vitalii Elenhaupt
904b5beec2
Lint/UnusedArgument: fails to recognized used argument inside macro
closes #117
2019-10-27 21:32:55 +02:00
Vitalii Elenhaupt
677c75716f
Typeof scope 2019-10-27 21:22:33 +02:00
Vitalii Elenhaupt
b868d88a85
CyclomaticCompexity: report onle def name 2019-07-12 23:33:08 +03:00
Vitalii Elenhaupt
ffa5dc9b4c
Crystal 0.29 fixes (#109)
* Fixes vs crystal head

* Use crystal nightly

* Remove trailing ? from local variable

* Do not use ? in the lhs

ref https://github.com/crystal-lang/crystal/issues/6685#issuecomment-419758587

* Upgrade to crystal 0.29.0 (warnings free) (#108)

* Remove trailing ? from local variable (take 2)

* Fix Time.now deprecation warnings

* Remove Crystal nightly
2019-06-06 19:10:26 +03:00
Vitalii Elenhaupt
037d1dde74
Performance/FirstLastAfterFilter: ignore .first/.last with args
closes #104
2019-06-03 18:25:48 +03:00
Vitalii Elenhaupt
94e1d4567a
Properly report performance rules in macros
closes #102
2019-05-05 18:05:08 +03:00
Vitalii Elenhaupt
f6a57f9272
Set default severities 2019-04-14 12:15:38 +03:00
Vitalii Elenhaupt
3a71b86193
Properly report literals (#96) 2019-03-23 19:20:32 +02:00
Sijawusz Pur Rahnama
e8a68a80d5 Fix several misspellings (#94) 2019-02-23 07:06:28 +02: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
Vitalii Elenhaupt
866af184f1
Redundant return (#87) 2018-12-30 09:04:59 +02:00
Vitalii Elenhaupt
32ac199162
Correct trailing blank line position 2018-12-24 00:44:15 +02:00
Vitalii Elenhaupt
60ce034f1b
UnusedArgument: fix crystal upgrade regression 2018-12-12 22:21:33 +02:00
Vitalii Elenhaupt
f8dab3bc34
MethodNames: correct reported location/end_location 2018-11-25 00:56:21 +02:00
Vitalii Elenhaupt
e951c0772a
ConstantNames: correct reported end_location 2018-11-25 00:37:46 +02:00
Vitalii Elenhaupt
9885457227
Track issue.end_location properly 2018-11-24 19:38:13 +02:00
V. Elenhaupt
0fd5890738
Extend UnreachableCode rule: handle control flow (#83) 2018-11-22 10:38:32 +02:00
Vitalii Elenhaupt
eca0f3f350
Handle raise, exit, abort in unreachable code 2018-11-11 20:33:48 +02:00
Vitalii Elenhaupt
67d76116f7
Basic implementation of UnreachableCode rule 2018-11-05 21:39:27 +02:00
Vitalii Elenhaupt
12aa48c98f
Fix Style/RedundantBegin: begin-end in a proc literal
closes #80
2018-09-22 21:58:38 +03:00
Vitalii Elenhaupt
d7b0e10d1e
Normalize sources for tests 2018-09-07 15:07:03 +03:00
V. Elenhaupt
cb5f802012
Correctly process record declaration at a top level (#78) 2018-09-07 00:47:02 +03:00
V. Elenhaupt
fd78d17c40
New rule: Performance/FirstLastAfterFilter (#76) 2018-09-06 17:59:11 +03:00
Vitalii Elenhaupt
a1b34eb7be
New rule: Performance/AnyAfterFilter 2018-09-03 22:55:10 +03:00
Vitalii Elenhaupt
790b519653
Performance/Count -> Performance/SizeAfterFilter 2018-09-03 22:44:30 +03:00
Vitalii Elenhaupt
799c0fd5e1
Correct location name of reported issue 2018-09-03 13:26:19 +03:00
Vitalii Elenhaupt
446f557c23
New rule: Performance/Count 2018-09-03 01:07:34 +03:00
Vitalii Elenhaupt
248c5a656b
Add --all cli flag that enables all available rules 2018-07-04 15:20:35 +03:00
Vitalii Elenhaupt
dbac46b68a
Ignore outer shadowing of throwaway variables
closes #67
2018-06-25 17:02:46 +03:00
Vitalii Elenhaupt
04c7300964
Handle type declarations in scopes
closes #66
2018-06-23 08:48:13 +03:00
V. Elenhaupt
fafc5f4bdc
Allow filtering by group name (#65) 2018-06-18 10:25:06 +03:00