Skip to content

Commit b6b04f9

Browse files
Customize ameba configuration
1 parent 205db93 commit b6b04f9

File tree

7 files changed

+86
-74
lines changed

7 files changed

+86
-74
lines changed

.ameba.yml

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,106 @@
11
# This configuration file was generated by `ameba --gen-config`
2-
# on 2025-05-27 13:38:25 UTC using Ameba version 1.7.0-dev.
2+
# on 2025-06-02 13:57:07 UTC using Ameba version 1.7.0-dev.
33
# The point is for the user to remove these configuration records
44
# one by one as the reported problems are removed from the code base.
55
#
66
# For more details on any individual rule, run `ameba --only RuleName`.
77

88
Version: "1.7.0-dev"
99

10-
Documentation/DocumentationAdmonition:
11-
Enabled: false
10+
# Documentation
11+
# =========================
1212

13-
Layout/TrailingBlankLines:
13+
# Disabled: What's the point in alerting about existing TODOs in code?
14+
Documentation/DocumentationAdmonition:
1415
Enabled: false
1516

16-
Layout/TrailingWhitespace:
17-
Enabled: false
17+
# Lint
18+
# =========================
1819

1920
Lint/DebugCalls:
20-
Enabled: false
21+
Excluded:
22+
# Samples may legitimately use DebugCalls
23+
- samples/**/*
24+
# Explicit tests
25+
- spec/std/pp_spec.cr
2126

2227
Lint/DebuggerStatement:
23-
Enabled: false
28+
Excluded:
29+
# Explicit tests
30+
- spec/debug/**/*
2431

32+
# Disabled: `else nil` can be useful to explicitly show the consequence of the else branch
2533
Lint/ElseNil:
2634
Enabled: false
2735

28-
Lint/EmptyLoop:
29-
Enabled: false
30-
31-
Lint/HashDuplicatedKey:
32-
Enabled: false
33-
3436
Lint/LiteralInCondition:
35-
Enabled: false
37+
Excluded:
38+
# Samples may legitimately use literals in conditions
39+
- samples/**/*
3640

3741
Lint/LiteralInInterpolation:
38-
Enabled: false
42+
Excluded:
43+
- spec/std/random_spec.cr # BUG: https://github.com/crystal-ameba/ameba/issues/611
3944

4045
Lint/LiteralsComparison:
41-
Enabled: false
46+
Excluded:
47+
# Explicit tests for case equality on tuple literals
48+
- spec/std/tuple_spec.cr
4249

50+
# TODO: Investigate if some `not_nil!` calls can be avoided.
4351
Lint/NotNil:
4452
Enabled: false
4553

46-
Lint/NotNilAfterNoBang:
47-
Enabled: false
48-
4954
Lint/RandZero:
50-
Enabled: false
51-
52-
Lint/ShadowedArgument:
53-
Enabled: false
55+
Excluded:
56+
# Explicit tests
57+
- spec/std/random_spec.cr
5458

59+
# FIXME: Resolve shadowing.
5560
Lint/ShadowingOuterLocalVar:
5661
Enabled: false
5762

58-
Lint/SignalTrap:
59-
Enabled: false
60-
61-
Lint/SpecEqWithBoolOrNilLiteral:
62-
Enabled: false
63-
63+
# TODO: Investigate file names and move to data directories.
6464
Lint/SpecFilename:
6565
Enabled: false
6666

67+
# BUG: https://github.com/crystal-ameba/ameba/issues/612
6768
Lint/TopLevelOperatorDefinition:
6869
Enabled: false
6970

71+
# Disabled: We're running typos explicitly in CI, no need for this rule.
7072
Lint/Typos:
7173
Enabled: false
7274

73-
Lint/UnreachableCode:
75+
# Disabled: We have an explicit CI job for `typos`. No reason to run it through
76+
# ameba.
77+
Lint/Typos:
7478
Enabled: false
7579

80+
# TODO: Investigate unused arguments.
7681
Lint/UnusedArgument:
7782
Enabled: false
7883

84+
# TODO: Investigate unused block arguments.
7985
Lint/UnusedBlockArgument:
8086
Enabled: false
8187

82-
Lint/UnusedComparison:
83-
Enabled: false
84-
85-
Lint/UnusedInstanceVariableAccess:
86-
Enabled: false
87-
88-
Lint/UnusedLiteral:
89-
Enabled: false
90-
91-
Lint/UnusedLocalVariableAccess:
92-
Enabled: false
93-
94-
Lint/UnusedSelfAccess:
95-
Enabled: false
96-
88+
# FIXME: Investigate useless assigns.
9789
Lint/UselessAssign:
9890
Enabled: false
9991

92+
# Metrics
93+
# =========================
94+
95+
# Disabled: Lot's of violations. Complexity is very individual.
10096
Metrics/CyclomaticComplexity:
10197
Enabled: false
10298

99+
# Naming
100+
# =========================
101+
# All disabled. There are many violations and some of the rules are questionable.
102+
# TODO: Consider enabling some of these rules.
103+
103104
Naming/AccessorMethodName:
104105
Enabled: false
105106

@@ -109,6 +110,8 @@ Naming/BinaryOperatorParameterName:
109110
Naming/BlockParameterName:
110111
Enabled: false
111112

113+
# Disabled: All violations follow the spelling of identifiers in upstream
114+
# projects, e.g. for lib bindings.
112115
Naming/ConstantNames:
113116
Enabled: false
114117

@@ -130,36 +133,36 @@ Naming/TypeNames:
130133
Naming/VariableNames:
131134
Enabled: false
132135

133-
Performance/AnyInsteadOfEmpty:
134-
Enabled: false
136+
# Performance
137+
# =========================
135138

136-
Performance/ChainedCallWithNoBang:
137-
Enabled: false
139+
Performance/AnyInsteadOfEmpty:
140+
Excluded:
141+
# These specs explicitly test `#any?` implementations
142+
- spec/std/bit_array_spec.cr
143+
- spec/std/enumerable_spec.cr
144+
- spec/std/hash_spec.cr
138145

139-
Performance/FlattenAfterMap:
140-
Enabled: false
141-
142-
Performance/MinMaxAfterMap:
143-
Enabled: false
146+
# Style
147+
# =========================
148+
# All disabled. There are many violations and some of the rules are questionable.
149+
# TODO: Consider enabling some of these rules.
144150

145151
Style/HeredocEscape:
146152
Enabled: false
147153

148154
Style/HeredocIndent:
149155
Enabled: false
150156

151-
Style/IsAFilter:
152-
Enabled: false
153-
154-
Style/IsANil:
155-
Enabled: false
156-
157157
Style/MultilineCurlyBlock:
158158
Enabled: false
159159

160+
# Disabled: This rule seems too strict when any negation inside a complex condition is
161+
# considered a violation. Not sure if this is expected behaviour.
160162
Style/NegatedConditionsInUnless:
161163
Enabled: false
162164

165+
# BUG: https://github.com/crystal-ameba/ameba/issues/614
163166
Style/ParenthesesAroundCondition:
164167
Enabled: false
165168

.github/workflows/linux.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
# libffi is only available starting from the 1.2.2 build images
3232
- crystal_bootstrap_version: 1.0.0
3333
flags: "FLAGS=-Dwithout_ffi USE_PCRE1=true"
34-
- crystal_bootstrap_version: 1.16.3 # LATEST RELEASE
34+
- crystal_bootstrap_version: 1.15.1 # LATEST RELEASE
3535
steps:
3636
- name: Download Crystal source
3737
uses: actions/checkout@v4
@@ -101,3 +101,12 @@ jobs:
101101

102102
- name: Check Format
103103
run: bin/ci format
104+
105+
lint_ameba:
106+
runs-on: ubuntu-latest
107+
container: ghcr.io/crystal-ameba/ameba:sha-d861f4ed0f904e0ecdad11c26f98e968f7d95afa # 1.7.0-dev
108+
steps:
109+
- name: Download Crystal source
110+
uses: actions/checkout@v4
111+
112+
- run: ameba

scripts/generate_windows_zone_names.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ windows_zone_names_items = entries.compact_map do |tzdata_name, territory, windo
4545

4646
{windows_name, zone1.name, zone2.name, location.name}
4747
rescue err : Time::Location::InvalidLocationNameError
48-
pp err
48+
puts err
4949
nil
5050
end
5151

spec/llvm-ir/pass-closure-to-c-debug-loc.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ lib Foo
33
end
44

55
def raise(msg)
6-
while true
6+
while true # ameba:disable Lint/EmptyLoop
77
end
88
end
99

spec/std/iterator_spec.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ describe Iterator do
663663

664664
describe "uniq" do
665665
it "without block" do
666-
iter = (1..8).each.map { |x| x % 3 }.uniq
666+
iter = (1..8).each.map { |x| x % 3 }.uniq # ameba:disable Performance/ChainedCallWithNoBang
667667
iter.next.should eq(1)
668668
iter.next.should eq(2)
669669
iter.next.should eq(0)
@@ -806,7 +806,7 @@ describe Iterator do
806806
end
807807

808808
it "flattens nested struct iterators with internal state being value types" do
809-
iter = (1..2).each.map { |i| StructIter.new(10 * i + 1, 10 * i + 3) }.flatten
809+
iter = (1..2).each.map { |i| StructIter.new(10 * i + 1, 10 * i + 3) }.flatten # ameba:disable Performance/FlattenAfterMap
810810

811811
iter.next.should eq(11)
812812
iter.next.should eq(12)

spec/std/string_spec.cr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,14 +2266,14 @@ describe "String" do
22662266
end
22672267

22682268
it "compares with == when different strings same contents" do
2269-
s1 = "foo#{1}"
2270-
s2 = "foo#{1}"
2269+
s1 = "foo#{1}" # ameba:disable Lint/LiteralInInterpolation
2270+
s2 = "foo#{1}" # ameba:disable Lint/LiteralInInterpolation
22712271
s1.should eq(s2)
22722272
end
22732273

22742274
it "compares with == when different contents" do
2275-
s1 = "foo#{1}"
2276-
s2 = "foo#{2}"
2275+
s1 = "foo#{1}" # ameba:disable Lint/LiteralInInterpolation
2276+
s2 = "foo#{2}" # ameba:disable Lint/LiteralInInterpolation
22772277
s1.should_not eq(s2)
22782278
end
22792279

src/kernel.cr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ end
468468
# See also: `Object#inspect(io)`.
469469
def p(*objects)
470470
objects.each do |obj|
471-
p obj
471+
p obj # ameba:disable Lint/DebugCalls
472472
end
473473
objects
474474
end
@@ -482,7 +482,7 @@ end
482482
#
483483
# See `Object#inspect(io)`
484484
def p(**objects)
485-
p(objects) unless objects.empty?
485+
p(objects) unless objects.empty? # ameba:disable Lint/DebugCalls
486486
end
487487

488488
# Pretty prints *object* to `STDOUT` followed
@@ -501,7 +501,7 @@ end
501501
# See also: `Object#pretty_print(pp)`.
502502
def pp(*objects)
503503
objects.each do |obj|
504-
pp obj
504+
pp obj # ameba:disable Lint/DebugCalls
505505
end
506506
objects
507507
end
@@ -515,7 +515,7 @@ end
515515
#
516516
# See `Object#pretty_print(pp)`
517517
def pp(**objects)
518-
pp(objects) unless objects.empty?
518+
pp(objects) unless objects.empty? # ameba:disable Lint/DebugCalls
519519
end
520520

521521
# Registers the given `Proc` for execution when the program exits regularly.

0 commit comments

Comments
 (0)