File tree 9 files changed +29
-50
lines changed
9 files changed +29
-50
lines changed Original file line number Diff line number Diff line change 2
2
source "https://rubygems.org"
3
3
4
4
gem "concurrent-ruby" , "~> 1.0.0"
5
- gem "flay" , "~> 2.10"
6
- gem "json"
7
- gem "sexp_processor" , "~> 4.10"
5
+ gem "flay" , "~> 2.12"
6
+ gem "sexp_processor" , "~> 4.11"
8
7
9
8
gem "codeclimate-parser-client" ,
10
9
path : "/home/app/codeclimate-parser-client"
Original file line number Diff line number Diff line change 14
14
diff-lcs (1.2.5 )
15
15
erubis (2.7.0 )
16
16
excon (0.57.1 )
17
- flay (2.10 .0 )
17
+ flay (2.12 .0 )
18
18
erubis (~> 2.7.0 )
19
19
path_expander (~> 1.0 )
20
20
ruby_parser (~> 3.0 )
21
21
sexp_processor (~> 4.0 )
22
- json (1.8.3 )
23
22
method_source (0.8.2 )
24
- path_expander (1.0.2 )
23
+ path_expander (1.0.3 )
25
24
pry (0.10.3 )
26
25
coderay (~> 1.1.0 )
27
26
method_source (~> 0.8.1 )
40
39
diff-lcs (>= 1.2.0 , < 2.0 )
41
40
rspec-support (~> 3.3.0 )
42
41
rspec-support (3.3.0 )
43
- ruby_parser (3.10 .0 )
42
+ ruby_parser (3.11 .0 )
44
43
sexp_processor (~> 4.9 )
45
- sexp_processor (4.10 .0 )
44
+ sexp_processor (4.11 .0 )
46
45
slop (3.6.0 )
47
46
48
47
PLATFORMS
@@ -51,12 +50,11 @@ PLATFORMS
51
50
DEPENDENCIES
52
51
codeclimate-parser-client !
53
52
concurrent-ruby (~> 1.0.0 )
54
- flay (~> 2.10 )
55
- json
53
+ flay (~> 2.12 )
56
54
pry
57
55
rake
58
56
rspec
59
- sexp_processor (~> 4.10 )
57
+ sexp_processor (~> 4.11 )
60
58
61
59
BUNDLED WITH
62
60
1.10.6
Original file line number Diff line number Diff line change @@ -14,14 +14,13 @@ class Main < CC::Engine::Analyzers::Base
14
14
PATTERNS = [ "**/*.go" ] . freeze
15
15
DEFAULT_MASS_THRESHOLD = 100
16
16
DEFAULT_FILTERS = [
17
- "(ImportSpec ___)" ,
17
+ "(GenDecl _ (specs (ImportSpec ___)) _)" ,
18
+ "(comments ___)" ,
18
19
] . freeze
19
20
POINTS_PER_OVERAGE = 10_000
20
21
REQUEST_PATH = "/go"
21
- COMMENT_MATCHER = Sexp ::Matcher . parse ( "(_ (comments ___) ___)" )
22
22
23
23
def transform_sexp ( sexp )
24
- delete_comments! ( sexp )
25
24
sexp . delete_if { |node | node [ 0 ] == :name }
26
25
end
27
26
@@ -38,10 +37,6 @@ def process_file(file)
38
37
def default_filters
39
38
DEFAULT_FILTERS . map { |filter | Sexp ::Matcher . parse filter }
40
39
end
41
-
42
- def delete_comments! ( sexp )
43
- sexp . search_each ( COMMENT_MATCHER ) { |node | node . delete_at ( 1 ) }
44
- end
45
40
end
46
41
end
47
42
end
Original file line number Diff line number Diff line change @@ -14,14 +14,10 @@ class Main < CC::Engine::Analyzers::Base
14
14
DEFAULT_MASS_THRESHOLD = 75
15
15
DEFAULT_FILTERS = [
16
16
"(Stmt_Use ___)" ,
17
+ "(comments ___)" ,
17
18
] . freeze
18
19
POINTS_PER_OVERAGE = 35_000
19
20
REQUEST_PATH = "/php"
20
- COMMENT_MATCHER = Sexp ::Matcher . parse ( "(_ (comments ___) ___)" )
21
-
22
- def transform_sexp ( sexp )
23
- delete_comments! ( sexp )
24
- end
25
21
26
22
def use_sexp_lines?
27
23
false
@@ -36,10 +32,6 @@ def process_file(file)
36
32
def default_filters
37
33
DEFAULT_FILTERS . map { |filter | Sexp ::Matcher . parse filter }
38
34
end
39
-
40
- def delete_comments! ( sexp )
41
- sexp . search_each ( COMMENT_MATCHER ) { |node | node . delete_at ( 1 ) }
42
- end
43
35
end
44
36
end
45
37
end
Original file line number Diff line number Diff line change 3
3
require "flay"
4
4
require "concurrent"
5
5
require "digest"
6
- require "zlib"
7
6
8
7
##
9
8
# A thread-safe and stable hash subclass of Flay.
@@ -21,16 +20,6 @@ def initialize(option = nil)
21
20
end
22
21
end
23
22
24
- # Overwrite `NODE_NAMES` from Flay to assign all values on-demand instead of
25
- # using a predefined registry.
26
- Sexp ::NODE_NAMES . delete_if { true }
27
-
28
- Sexp ::NODE_NAMES . default_proc = lambda do |hash , key |
29
- # Use CRC checksums so hash values are order-independent (i.e. consistent
30
- # between runs).
31
- hash [ key ] = Zlib . crc32 ( key . to_s )
32
- end
33
-
34
23
class Sexp
35
24
attr_writer :mass
36
25
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ module CC::Engine::Analyzers
123
123
}
124
124
EOGO
125
125
126
- issues = run_engine ( engine_conf ) . strip . split ( "\0 " )
126
+ issues = run_engine ( engine_conf 25 ) . strip . split ( "\0 " )
127
127
expect ( issues ) . to be_empty
128
128
end
129
129
@@ -218,7 +218,7 @@ module CC::Engine::Analyzers
218
218
expect ( run_engine ( engine_conf ) ) . to be_empty
219
219
end
220
220
221
- def engine_conf
221
+ def engine_conf mass = 10
222
222
CC ::Engine ::Analyzers ::EngineConfig . new ( {
223
223
'config' => {
224
224
'checks' => {
@@ -231,7 +231,7 @@ def engine_conf
231
231
} ,
232
232
'languages' => {
233
233
'go' => {
234
- 'mass_threshold' => 10 ,
234
+ 'mass_threshold' => mass ,
235
235
} ,
236
236
} ,
237
237
} ,
Original file line number Diff line number Diff line change 159
159
b = require('bar'),
160
160
c = require('baz'),
161
161
d = require('bam');
162
+ a + b + c + d;
162
163
EOJS
163
164
164
165
create_source_file ( "bar.js" , <<~EOJS )
165
166
const a = require('foo'),
166
167
b = require('bar'),
167
168
c = require('baz'),
168
169
d = require('bam');
170
+ print(a);
169
171
EOJS
170
172
171
- issues = run_engine ( engine_conf ) . strip . split ( "\0 " )
173
+ issues = run_engine ( engine_conf 3 ) . strip . split ( "\0 " )
172
174
expect ( issues ) . to be_empty
173
175
end
174
176
201
203
} )
202
204
end
203
205
204
- def engine_conf
206
+ def engine_conf mass = 1
205
207
CC ::Engine ::Analyzers ::EngineConfig . new ( {
206
208
'config' => {
207
209
'checks' => {
@@ -214,7 +216,7 @@ def engine_conf
214
216
} ,
215
217
'languages' => {
216
218
'javascript' => {
217
- 'mass_threshold' => 1 ,
219
+ 'mass_threshold' => mass ,
218
220
} ,
219
221
} ,
220
222
} ,
Original file line number Diff line number Diff line change 177
177
use KeepClear\\ Traits\\ Controllers\\ ApiFilter;
178
178
use KeepClear\\ Traits\\ Controllers\\ ApiParseBody;
179
179
use KeepClear\\ Traits\\ Controllers\\ ApiException;
180
+ a / b;
180
181
EOPHP
181
182
182
183
create_source_file ( "bar.php" , <<~EOPHP )
190
191
use KeepClear\\ Traits\\ Controllers\\ ApiFilter;
191
192
use KeepClear\\ Traits\\ Controllers\\ ApiParseBody;
192
193
use KeepClear\\ Traits\\ Controllers\\ ApiException;
194
+ a + b;
193
195
EOPHP
194
196
195
- issues = run_engine ( engine_conf ) . strip . split ( "\0 " )
197
+ issues = run_engine ( engine_conf 6 ) . strip . split ( "\0 " )
196
198
expect ( issues ) . to be_empty
197
199
end
198
200
275
277
end
276
278
end
277
279
278
- def engine_conf
280
+ def engine_conf mass = 5
279
281
CC ::Engine ::Analyzers ::EngineConfig . new ( {
280
282
'config' => {
281
283
'languages' => {
282
284
'php' => {
283
- 'mass_threshold' => 5 ,
285
+ 'mass_threshold' => mass ,
284
286
} ,
285
287
} ,
286
288
} ,
Original file line number Diff line number Diff line change 140
140
b = require('bar'),
141
141
c = require('baz'),
142
142
d = require('bam');
143
+ print(a);
143
144
EOTS
144
145
145
146
create_source_file ( "bar.ts" , <<~EOTS )
146
147
const a = require('foo'),
147
148
b = require('bar'),
148
149
c = require('baz'),
149
150
d = require('bam');
151
+ c * d;
150
152
EOTS
151
153
152
- issues = run_engine ( engine_conf ) . strip . split ( "\0 " )
154
+ issues = run_engine ( engine_conf 3 ) . strip . split ( "\0 " )
153
155
expect ( issues ) . to be_empty
154
156
end
155
157
209
211
expect ( json [ "fingerprint" ] ) . to eq ( "d8f0315c3c4e9ba81003a7ec6c823fb0" )
210
212
end
211
213
212
- def engine_conf
214
+ def engine_conf mass = 1
213
215
CC ::Engine ::Analyzers ::EngineConfig . new ( {
214
216
'config' => {
215
217
'checks' => {
@@ -222,7 +224,7 @@ def engine_conf
222
224
} ,
223
225
'languages' => {
224
226
'typescript' => {
225
- 'mass_threshold' => 1 ,
227
+ 'mass_threshold' => mass ,
226
228
} ,
227
229
} ,
228
230
} ,
You can’t perform that action at this time.
0 commit comments