pippi 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -10
- data/README.md +30 -3
- data/doc/docs.md +18 -2
- data/lib/pippi.rb +1 -0
- data/lib/pippi/check_set_mapper.rb +1 -0
- data/lib/pippi/checks/map_followed_by_flatten.rb +2 -2
- data/lib/pippi/checks/select_followed_by_select.rb +49 -0
- data/lib/pippi/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71a917fd7fe564b1259bbe2e1bd5816f99642c95
|
4
|
+
data.tar.gz: 04ee328c79590242bdf9901dfbf19128c20174fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4322323a5f61a25e4697774e900c403aaa17a206dc721583d0778ffe32337f8a791bae64c9dd17967c2ed778f34e08b40f9b09c97ec3bbd8fe8f2f3f2a906dcb
|
7
|
+
data.tar.gz: 46c707010d0424970e002c07a90f21ab8a37a633a955afcba21be1331f7b667c477026bb5de0bfe81d35eaa42a14eec6c65ff22d7a7dcd532b64b95ab840f4e3
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,25 @@
|
|
1
|
-
|
2
|
-
Added SelectFollowedByEmpty
|
1
|
+
## 0.0.6 (2014-11-18)
|
3
2
|
|
4
|
-
|
5
|
-
Bugfixes around method delegation
|
3
|
+
* [NEW] Added SelectFollowedBySelect
|
6
4
|
|
7
|
-
|
8
|
-
Moved AssertWithNil to "buggy" checkset until I can figure out issues.
|
5
|
+
## 0.0.5 (2014-11-05)
|
9
6
|
|
10
|
-
|
11
|
-
Added AssertWithNil
|
7
|
+
* [NEW] Added SelectFollowedByEmpty
|
12
8
|
|
13
|
-
|
14
|
-
|
9
|
+
## 0.0.4 (2014-10-30)
|
10
|
+
|
11
|
+
* [FIXED] Bugfixes around method delegation
|
12
|
+
|
13
|
+
## 0.0.3 (2014-10-22)
|
14
|
+
|
15
|
+
* [CHANGED] Moved AssertWithNil to "buggy" checkset until I can figure out issues.
|
16
|
+
|
17
|
+
## 0.0.2 (2014-10-22)
|
18
|
+
|
19
|
+
* [NEW] Added AssertWithNil
|
20
|
+
|
21
|
+
## 0.0.1 (2014-10-22)
|
22
|
+
|
23
|
+
* [NEW] Initial release.
|
15
24
|
|
16
25
|
|
data/README.md
CHANGED
@@ -81,19 +81,28 @@ Here's a [demo Rails application](https://github.com/tcopeland/pippi_demo#pippi-
|
|
81
81
|
### Rails with rspec
|
82
82
|
|
83
83
|
* Add `gem 'pippi'` to the `test` group in your project's `Gemfile`
|
84
|
-
* Add this to the
|
84
|
+
* Add this to the top of `spec/spec_helper.rb`:
|
85
85
|
|
86
86
|
```ruby
|
87
87
|
if ENV['USE_PIPPI'].present?
|
88
|
+
require 'pippi'
|
88
89
|
Pippi::AutoRunner.new(:checkset => ENV['PIPPI_CHECKSET'] || "basic")
|
89
90
|
end
|
90
91
|
```
|
92
|
+
|
91
93
|
* Run it:
|
92
94
|
|
93
95
|
```text
|
94
96
|
USE_PIPPI=true bundle exec rake spec && cat log/pippi.log
|
95
97
|
```
|
96
98
|
|
99
|
+
### As part of a continuous integration job
|
100
|
+
|
101
|
+
[Dan Kohn](https://github.com/dankohn) suggests you could use something like:
|
102
|
+
|
103
|
+
```bash
|
104
|
+
if grep -v gem < log/pippi.log; then echo "$(wc -l < log/pippi.log) Pippi flaws found" && false; else echo 'No pippi flaws found'; fi
|
105
|
+
```
|
97
106
|
|
98
107
|
### From the command line:
|
99
108
|
|
@@ -164,6 +173,22 @@ Instead, consider doing this:
|
|
164
173
|
[1,2,3].detect {|x| x > 1 }
|
165
174
|
```
|
166
175
|
|
176
|
+
#### SelectFollowedBySelect
|
177
|
+
|
178
|
+
Don't use consecutive select blocks; use a single select instead
|
179
|
+
|
180
|
+
For example, rather than doing this:
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
[1,2,3].select {|x| x > 1 }.select {|x| x > 2 }
|
184
|
+
```
|
185
|
+
|
186
|
+
Instead, consider doing this:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
[1,2,3].select {|x| x > 2 }
|
190
|
+
```
|
191
|
+
|
167
192
|
#### SelectFollowedBySize
|
168
193
|
|
169
194
|
Don't use select followed by size; use count instead
|
@@ -199,12 +224,12 @@ x = nil ; assert_nil(x)
|
|
199
224
|
|
200
225
|
#### MapFollowedByFlatten
|
201
226
|
|
202
|
-
Don't use map followed by flatten; use flat_map instead
|
227
|
+
Don't use map followed by flatten(1); use flat_map instead
|
203
228
|
|
204
229
|
For example, rather than doing this:
|
205
230
|
|
206
231
|
```ruby
|
207
|
-
[1,2,3].map {|x| [x,x+1] }.flatten
|
232
|
+
[1,2,3].map {|x| [x,x+1] }.flatten(1)
|
208
233
|
```
|
209
234
|
|
210
235
|
Instead, consider doing this:
|
@@ -212,6 +237,7 @@ Instead, consider doing this:
|
|
212
237
|
```ruby
|
213
238
|
[1,2,3].flat_map {|x| [x, x+1]}
|
214
239
|
```
|
240
|
+
|
215
241
|
## Ideas for other problems to detect:
|
216
242
|
|
217
243
|
```ruby
|
@@ -306,6 +332,7 @@ rm -rf pippi_debug.log pippi.log .bundle/gems/pippi-0.0.1/ .bundle/cache/pippi-0
|
|
306
332
|
* Commit, push
|
307
333
|
* `bundle exec gem build pippi.gemspec`
|
308
334
|
* `gem push pippi-x.gem`
|
335
|
+
* Update pippi_demo
|
309
336
|
|
310
337
|
## Credits
|
311
338
|
|
data/doc/docs.md
CHANGED
@@ -48,6 +48,22 @@ Instead, consider doing this:
|
|
48
48
|
[1,2,3].detect {|x| x > 1 }
|
49
49
|
```
|
50
50
|
|
51
|
+
#### SelectFollowedBySelect
|
52
|
+
|
53
|
+
Don't use select followed by select; use a single select instead
|
54
|
+
|
55
|
+
For example, rather than doing this:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
[1,2,3].select {|x| x > 1 }.select {|x| x > 2 }
|
59
|
+
```
|
60
|
+
|
61
|
+
Instead, consider doing this:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
[1,2,3].select {|x| x > 2 }
|
65
|
+
```
|
66
|
+
|
51
67
|
#### SelectFollowedBySize
|
52
68
|
|
53
69
|
Don't use select followed by size; use count instead
|
@@ -83,12 +99,12 @@ x = nil ; assert_nil(x)
|
|
83
99
|
|
84
100
|
#### MapFollowedByFlatten
|
85
101
|
|
86
|
-
Don't use map followed by flatten; use flat_map instead
|
102
|
+
Don't use map followed by flatten(1); use flat_map instead
|
87
103
|
|
88
104
|
For example, rather than doing this:
|
89
105
|
|
90
106
|
```ruby
|
91
|
-
[1,2,3].map {|x| [x,x+1] }.flatten
|
107
|
+
[1,2,3].map {|x| [x,x+1] }.flatten(1)
|
92
108
|
```
|
93
109
|
|
94
110
|
Instead, consider doing this:
|
data/lib/pippi.rb
CHANGED
@@ -13,5 +13,6 @@ require 'pippi/checks/reverse_followed_by_each'
|
|
13
13
|
require 'pippi/checks/select_followed_by_first'
|
14
14
|
require 'pippi/checks/select_followed_by_size'
|
15
15
|
require 'pippi/checks/select_followed_by_empty'
|
16
|
+
require 'pippi/checks/select_followed_by_select'
|
16
17
|
require 'pippi/checks/assert_with_nil'
|
17
18
|
require 'pippi/checks/debug_check'
|
@@ -41,11 +41,11 @@ module Pippi::Checks
|
|
41
41
|
|
42
42
|
class Documentation
|
43
43
|
def description
|
44
|
-
"Don't use map followed by flatten; use flat_map instead"
|
44
|
+
"Don't use map followed by flatten(1); use flat_map instead"
|
45
45
|
end
|
46
46
|
|
47
47
|
def sample
|
48
|
-
'[1,2,3].map {|x| [x,x+1] }.flatten'
|
48
|
+
'[1,2,3].map {|x| [x,x+1] }.flatten(1)'
|
49
49
|
end
|
50
50
|
|
51
51
|
def instead_use
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pippi::Checks
|
2
|
+
|
3
|
+
class SelectFollowedBySelect < Check
|
4
|
+
|
5
|
+
module MySecondSelect
|
6
|
+
def select(&blk)
|
7
|
+
self.class._pippi_check_select_followed_by_select.add_problem
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module MyFirstSelect
|
13
|
+
def select(&blk)
|
14
|
+
result = super
|
15
|
+
if !self.class._pippi_check_select_followed_by_select.nil?
|
16
|
+
result.extend MySecondSelect
|
17
|
+
self.class._pippi_check_select_followed_by_select.array_mutator_methods.each do |this_means_its_ok_sym|
|
18
|
+
result.define_singleton_method(this_means_its_ok_sym, self.class._pippi_check_select_followed_by_select.its_ok_watcher_proc(MySecondSelect, :select))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
result
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def decorate
|
26
|
+
Array.class_exec(self) do |my_check|
|
27
|
+
@_pippi_check_select_followed_by_select = my_check
|
28
|
+
def self._pippi_check_select_followed_by_select
|
29
|
+
@_pippi_check_select_followed_by_select
|
30
|
+
end
|
31
|
+
end
|
32
|
+
Array.prepend MyFirstSelect
|
33
|
+
end
|
34
|
+
|
35
|
+
class Documentation
|
36
|
+
def description
|
37
|
+
"Don't use consecutive select blocks; use a single select instead"
|
38
|
+
end
|
39
|
+
def sample
|
40
|
+
"[1,2,3].select {|x| x > 1 }.select {|x| x > 2 }"
|
41
|
+
end
|
42
|
+
def instead_use
|
43
|
+
"[1,2,3].select {|x| x > 2 }"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/lib/pippi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pippi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Copeland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/pippi/checks/reverse_followed_by_each.rb
|
77
77
|
- lib/pippi/checks/select_followed_by_empty.rb
|
78
78
|
- lib/pippi/checks/select_followed_by_first.rb
|
79
|
+
- lib/pippi/checks/select_followed_by_select.rb
|
79
80
|
- lib/pippi/checks/select_followed_by_size.rb
|
80
81
|
- lib/pippi/context.rb
|
81
82
|
- lib/pippi/exec_runner.rb
|