-
Notifications
You must be signed in to change notification settings - Fork 20
/
template.yml
71 lines (64 loc) · 1.81 KB
/
template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
rules:
- id: sample.debug_print
pattern:
- self.p
- self.pp
message: Delete debug print
examples:
- before: |
pp some: error
- id: sample.file.open
pattern: File.open(...) !{}
message: |
Use block to read/write file
If you use block, the open method closes file implicitly.
You don't have to close files explicitly.
examples:
- before: |
io = File.open("foo.txt")
io.write("hello world")
io.close
after: |
File.open("foo.txt") do |io|
io.write("hello world")
end
- id: sample.exception
pattern: Exception
message: |
You probably should use StandardError
If you are trying to define error class, inherit that from StandardError.
justification:
- You are sure you want to define an exception which is not rescued by default
examples:
- before: class MyError < Exception; end
after: class MyError < StandardError; end
- id: sample.test.assert_equal_size
pattern:
subject: "assert_equal(:int: as 'zero, _.'size, ...)"
where:
zero: 0
size:
- size
- count
message: |
Comparing size of something with 0 can be written using assert_empty
examples:
- before: |
assert_equal 0, some.size
after: |
assert_empty some.size
- before: |
assert_equal 0, some.count
after: |
assert_empty some.count
preprocessor:
# .slim: slimrb --compile # Install `slim` gem for slim support
# .erb: querly-pp erb # Install `better_erb` gem for erb support
# .haml: querly-pp haml # Install `haml` gem for haml support
check:
- path: /
rules:
- except: sample.test
- path: /test
rules:
- append: sample.test