Commit graph

511 commits

Author SHA1 Message Date
Vitalii Elenhaupt
17e9566c7e
fix(lint): Lint/UnusedBlockArgument is triggered by abstract def
closes #352
2023-02-19 10:51:52 +02:00
Vitalii Elenhaupt
031c1daf58
chore: fix crystal-nightly compatibility 2023-02-19 09:30:05 +02:00
Vitalii Elenhaupt
d20cc212b9
Styling changes 2023-02-07 20:03:52 +02:00
Vitalii Elenhaupt
6b2ddcb1d9
Address feedback, add tests 2023-02-07 17:19:04 +02:00
Vitalii Elenhaupt
14a9ec3a75
Incorporate changes for shadowing outer local var 2023-02-04 20:53:41 +02:00
Vitalii Elenhaupt
ddbcf5cb3f
fix(lint): useless assignment for type definition
closes #342
2023-02-04 16:57:46 +02:00
Sijawusz Pur Rahnama
ce4dd7236a Make Lint/NotNilAfterNoBang report calls to #rindex 2023-01-10 13:37:28 +01:00
Sijawusz Pur Rahnama
3b79392ef2 Simplify implementation of Lint/EmptyExpression rule 2023-01-10 13:10:05 +01:00
Sijawusz Pur Rahnama
6f0b6ffcd0 Remove buggy auto-correction from Performance/AnyInsteadOfEmpty rule 2023-01-04 02:40:07 +01:00
Sijawusz Pur Rahnama
caaf803ecd Tweak reported location for Style/UnlessElse 2022-12-23 14:46:45 +01:00
Sijawusz Pur Rahnama
bbbfdfc5a2 Tweak reported location for Lint/UnusedBlockArgument 2022-12-23 14:46:23 +01:00
Sijawusz Pur Rahnama
2d9e328d97
Merge pull request #325 from FnControlOption/unless_else
Add autocorrect for `Style/UnlessElse`
2022-12-22 21:43:49 +01:00
Sijawusz Pur Rahnama
2cedd72b09 Apply review sugggestions 2022-12-22 19:18:27 +01:00
Sijawusz Pur Rahnama
4f8b79ec6b
Merge pull request #324 from crystal-ameba/Sija/extend-several-rule-with-corrections
Extend `Lint/UnusedArgument` and `Lint/UnusedBlockArgument` rules with corrections
2022-12-22 18:42:35 +01:00
Sijawusz Pur Rahnama
3586b4242f Extend Lint/UnusedBlockArgument rule with corrections 2022-12-22 17:15:46 +01:00
Sijawusz Pur Rahnama
f26cd7f823 Extend Lint/UnusedArgument rule with corrections 2022-12-22 17:15:46 +01:00
Sijawusz Pur Rahnama
b9bc5aaab2
Merge pull request #327 from crystal-ameba/Sija/specs-cleanup 2022-12-22 12:08:44 +01:00
Sijawusz Pur Rahnama
206b5ab604 Refactor: Source#correct -> Source#correct? 2022-12-20 17:04:34 +01:00
Sijawusz Pur Rahnama
cabf203e0d
Merge pull request #326 from crystal-ameba/Sija/lint-formatting 2022-12-20 16:20:48 +01:00
Sijawusz Pur Rahnama
47b92fbb76 Fix newly found issues 2022-12-20 15:31:14 +01:00
Sijawusz Pur Rahnama
597372c645 Add Lint/MissingBlockArgument rule 2022-12-20 15:31:14 +01:00
Sijawusz Pur Rahnama
3bc8bda008 Add Lint/Formatting rule 2022-12-20 04:10:56 +01:00
Sijawusz Pur Rahnama
4e3caf2986 Few tweaks and readability refactors 2022-12-20 03:26:13 +01:00
Sijawusz Pur Rahnama
ab059616b5 Switch from Hash to NamedTuple for AmbiguousAssignment::MISTAKES 2022-12-20 03:25:14 +01:00
Sijawusz Pur Rahnama
8112dddc8f Specs cleanup 2022-12-20 03:25:06 +01:00
fn ⌃ ⌥
d7795c0d7d Add autocorrect for Style/UnlessElse 2022-12-19 06:40:28 -08:00
Sijawusz Pur Rahnama
bb0c0eeec6 Consider previous_def implicitly accessing variables, in the same way as super does 2022-12-15 18:35:16 +01:00
Sijawusz Pur Rahnama
b6f3d41211 Small refactor 2022-12-15 18:35:16 +01:00
Sijawusz Pur Rahnama
7f6bd2289e Do not report unused block arguments in Lint/UnusedArgument rule 2022-12-15 18:35:16 +01:00
Sijawusz Pur Rahnama
858557bc07 Add Lint/UnusedBlockArgument rule 2022-12-15 18:35:16 +01:00
Sijawusz Pur Rahnama
6ffb635dcc Add Scope#yields? 2022-12-15 18:35:16 +01:00
Sijawusz Pur Rahnama
9df66e890b Do not report anonymous block arguments in Lint/UnusedArgument 2022-12-12 18:21:19 +01:00
Sijawusz Pur Rahnama
4d9cd4d56c Fix typo 2022-12-10 00:24:04 +01:00
Sijawusz Pur Rahnama
a8fca61b22 Doc tweaks 2022-12-10 00:20:20 +01:00
Sijawusz Pur Rahnama
2dc21a00d9 Remove treating paths as literals in AST::Util#literal? & friends 2022-12-08 17:47:22 +01:00
Sijawusz Pur Rahnama
0bd4ed0c45 Do not treat paths as literals in Lint/LiteralAssignmentsInExpressions 2022-12-08 17:47:22 +01:00
Sijawusz Pur Rahnama
db3ef762b9 Uncomment forgotten line 2022-12-08 17:47:22 +01:00
Sijawusz Pur Rahnama
07ce595ef2 Readability refactors 2022-12-08 17:47:22 +01:00
Sijawusz Pur Rahnama
784e3ac616 Use bang variants in couple of places more 2022-12-08 13:59:42 +01:00
Sijawusz Pur Rahnama
5ab4b05add Fix incorrect Reportable#add_issue(&) definition 2022-12-08 13:59:03 +01:00
Sijawusz Pur Rahnama
7d88455b7f Add corrector to the Style/IsANil rule 2022-12-08 13:58:35 +01:00
Sijawusz Pur Rahnama
2cb8c1381f Don’t treat crystal paths as literals in Lint/LiteralsComparison 2022-12-08 13:55:29 +01:00
Sijawusz Pur Rahnama
cdf0405496 Refactor Style/IsANil rule to use newly added path_named? helper 2022-12-08 02:16:16 +01:00
Sijawusz Pur Rahnama
f45d6a2ef0 Fix newly found issue 2022-12-08 02:16:16 +01:00
Sijawusz Pur Rahnama
1524aad299 Add Style/QueryBoolMethods rule 2022-12-08 02:16:16 +01:00
Sijawusz Pur Rahnama
4dd62a3ed1 Colorize also the code in single backticks 2022-11-28 11:49:26 +01:00
Sijawusz Pur Rahnama
2113e8c055 Refactor MacroReferenceFinder class a bit 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
a8f953a2b2 Compress identical method definitions 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
b79f3e6e07 Minor refactors in Style/LargeNumbers rule 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
134963ece7 Minor details 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
523a622b34 Remove leftover from some merge/rebase gone wrong 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
5502f0f8d1 Small refactor using Object#in? 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
748cab29b4 Remove redundant empty comment lines 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
629e65127d if … == nil -> unless … 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
adff510cb6 Autocasting will do the work 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
33ef9c6293 Refactor ExplainFormatter 2022-11-28 11:38:41 +01:00
Sijawusz Pur Rahnama
f9b05a309e Redundant whitespace before nl 2022-11-28 11:25:21 +01:00
Sijawusz Pur Rahnama
0f893971dc Avoid one-letter names if possible 2022-11-28 11:25:21 +01:00
Sijawusz Pur Rahnama
d19d3b78c4 Implement Severity#color property 2022-11-28 06:07:19 +01:00
Sijawusz Pur Rahnama
6a180757f3 Use Enumerable#zip ftw 2022-11-23 16:16:34 +01:00
Sijawusz Pur Rahnama
1399aa3cdf Doc fixes 2022-11-23 16:16:03 +01:00
Sijawusz Pur Rahnama
75482a06cf Use warning as a default severity for Metrics and Performance groups 2022-11-23 15:06:24 +01:00
Sijawusz Pur Rahnama
3b7cd3723c Refactor rules’ default group severity handling 2022-11-23 15:04:47 +01:00
Sijawusz Pur Rahnama
735ec2462a Refactor usages of \ to sth more readable if possible 2022-11-23 05:50:32 +01:00
Sijawusz Pur Rahnama
2c67fe2c3f Use tuple instead of an array 2022-11-23 03:23:42 +01:00
Sijawusz Pur Rahnama
8b43a40a65 Misc refactors 2022-11-23 03:22:27 +01:00
Sijawusz Pur Rahnama
ffd63ef028 Fix typo in AST::Branchable example 2022-11-23 03:21:49 +01:00
Sijawusz Pur Rahnama
4500181ddb Remove redundant blank comment lines 2022-11-23 03:21:15 +01:00
Sijawusz Pur Rahnama
2af58cabd4 Use property? for defining Bool-returning Rule properties 2022-11-22 19:49:16 +01:00
Sijawusz Pur Rahnama
c7c75ee36a Rule#enabled -> Rule#enabled? 2022-11-22 19:47:37 +01:00
Sijawusz Pur Rahnama
31392046e0 Always return Bool value from Rule#excluded? 2022-11-22 19:45:16 +01:00
Sijawusz Pur Rahnama
39cc286263 Use tuple instead of array for Rule::SPECIAL 2022-11-22 19:44:38 +01:00
Sijawusz Pur Rahnama
5ee4074c1b Rename RedundantParentheses -> ParenthesesAroundCondition
Also rename the option: `parenthesized_assignments` -> `allow_safe_assignment`
2022-11-18 21:06:51 +01:00
Sijawusz Pur Rahnama
eabe463386 Instead of adding the new rule to support enforcing parens around assignments, refactor existing RedundantParentheses rule 2022-11-18 05:27:05 +01:00
Sijawusz Pur Rahnama
94a271b2a1 Add Style/ParenthesizedAssignments rule 2022-11-17 21:32:47 +01:00
Sijawusz Pur Rahnama
496e8930e2
Merge pull request #303 from crystal-ameba/Sija/lint-literal-assignments-in-expressions-rule
Add `Lint/LiteralAssignmentsInExpressions` rule
2022-11-17 14:19:17 +01:00
Sijawusz Pur Rahnama
95d68114c7 Fix typos throughout the code 2022-11-16 16:55:32 +01:00
Sijawusz Pur Rahnama
f9b6b17657
Merge pull request #305 from crystal-ameba/Sija/followup-to-pr-300
Few more readability refactors
2022-11-16 16:26:59 +01:00
Sijawusz Pur Rahnama
5c08b64e72 Add Lint/LiteralAssignmentsInExpressions rule 2022-11-16 15:08:41 +01:00
Sijawusz Pur Rahnama
28e2871165
Merge pull request #301 from crystal-ameba/Sija/style-redundant-parentheses-rule
Add `Style/RedundantParentheses` rule
2022-11-16 12:22:39 +01:00
Sijawusz Pur Rahnama
935296b041 Refactor ternary handling in Style/RedundantParentheses rule 2022-11-16 03:54:31 +01:00
Sijawusz Pur Rahnama
e54029d8ed Few more readability refactors 2022-11-15 20:55:32 +01:00
Sijawusz Pur Rahnama
76a4209706 Tweak comments in AST::Util 2022-11-15 17:42:08 +01:00
Sijawusz Pur Rahnama
2fb37da80f Refactor AST::Util#literal? helper 2022-11-15 17:42:08 +01:00
Sijawusz Pur Rahnama
3340613a6a Fix newly found issue 2022-11-15 15:17:32 +01:00
Sijawusz Pur Rahnama
cbf5d3de74 Add Style/RedundantParentheses rule 2022-11-15 15:17:32 +01:00
Sijawusz Pur Rahnama
04b19a60db
Merge pull request #300 from crystal-ameba/Sija/some-refactors
Misc refactors
2022-11-14 17:27:29 +01:00
Sijawusz Pur Rahnama
e668ba5bf5 Readability-related refactors 2022-11-14 02:26:52 +01:00
Sijawusz Pur Rahnama
a6ebb48f14 Remove redundant parentheses in if expressions
+ `elsif` -> `case`
2022-11-14 01:52:07 +01:00
Sijawusz Pur Rahnama
d1bfdaabeb Use #in? instead of #includes? in several places
Because:

1. it’s more semantically descriptive
2. it’s shorter
2022-11-14 01:18:43 +01:00
Sijawusz Pur Rahnama
ed6085e6a6 Several refactors in Style/GuardClause rule
Mostly readability related
2022-11-14 01:18:43 +01:00
Sijawusz Pur Rahnama
353c0a1583 Fix typo + add NOTE pragma 2022-11-14 01:05:13 +01:00
Sijawusz Pur Rahnama
5db7a2cf5a Turn on Style/PredicateName rule by default 2022-11-13 20:12:39 +01:00
Sijawusz Pur Rahnama
52bf0a5be4 Refactor Style/PredicateName rule
Do not report `has_<name>?` method names
2022-11-13 20:12:23 +01:00
Sijawusz Pur Rahnama
84540d2a22 Change to alternative approach skipping all macro contexts 2022-11-13 01:25:24 +01:00
Sijawusz Pur Rahnama
5491d31b5f Fix the edge case re: free var comparison 2022-11-13 01:24:59 +01:00
Sijawusz Pur Rahnama
aee5de517b Add Crystal::Path to the list of primitive types
So, the  comparisons like `Regex == 1=42` will also be detected.
2022-11-02 02:06:22 +01:00
Sijawusz Pur Rahnama
6bf8db81e3 Refactor Lint/StaticComparison to LiteralsComparison 2022-11-02 02:00:37 +01:00
Sijawusz Pur Rahnama
ea42911c3c Extend StaticComparison w/ support of === operator 2022-11-01 03:35:20 +01:00
Sijawusz Pur Rahnama
849be52618 Add Lint/StaticComparison rule 2022-11-01 03:34:28 +01:00