Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit fcdaf4a

Browse files
Upgrade to latest versions of flay and sexp_processor (#383)
* Update `flay` and `sexp_processor` gems * Monkey patch `sexp_processor` gem This applies a small monkey patch to the `parse_sexp` method in the `sexp_processor` gem. This will allow us to continue passing filters to `Sexp::Matcher.parse` like this: ``` DEFAULT_FILTERS = [ "(UsingDirective ___)".freeze ].freeze ```
1 parent b2c37e2 commit fcdaf4a

File tree

5 files changed

+81
-37
lines changed

5 files changed

+81
-37
lines changed

‎Gemfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
source "https://rubygems.org"
33

44
gem "concurrent-ruby", "~> 1.0.0"
5-
gem "flay", "~> 2.12"
6-
gem "sexp_processor", "~> 4.11"
5+
gem "flay", "~> 2.13.1"
6+
gem "sexp_processor", "~> 4.17"
77

88
gem "codeclimate-parser-client",
99
path: "/home/app/codeclimate-parser-client"

‎Gemfile.lock‎

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,51 @@ PATH
88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
ast (2.3.0)
12-
coderay (1.1.0)
13-
concurrent-ruby (1.0.0)
14-
diff-lcs (1.2.5)
15-
erubis (2.7.0)
11+
ast (2.4.2)
12+
coderay (1.1.3)
13+
concurrent-ruby (1.0.5)
14+
diff-lcs (1.5.0)
15+
erubi (1.12.0)
1616
excon (0.99.0)
17-
flay (2.12.0)
18-
erubis (~> 2.7.0)
17+
flay (2.13.1)
18+
erubi (~> 1.10)
1919
path_expander (~> 1.0)
2020
ruby_parser (~> 3.0)
2121
sexp_processor (~> 4.0)
22-
method_source (0.8.2)
23-
path_expander (1.0.3)
24-
pry (0.10.3)
25-
coderay (~> 1.1.0)
26-
method_source (~> 0.8.1)
27-
slop (~> 3.4)
28-
rake (10.4.2)
29-
rspec (3.3.0)
30-
rspec-core (~> 3.3.0)
31-
rspec-expectations (~> 3.3.0)
32-
rspec-mocks (~> 3.3.0)
33-
rspec-core (3.3.2)
34-
rspec-support (~> 3.3.0)
35-
rspec-expectations (3.3.1)
22+
method_source (1.0.0)
23+
path_expander (1.1.1)
24+
pry (0.14.2)
25+
coderay (~> 1.1)
26+
method_source (~> 1.0)
27+
rake (13.1.0)
28+
rspec (3.12.0)
29+
rspec-core (~> 3.12.0)
30+
rspec-expectations (~> 3.12.0)
31+
rspec-mocks (~> 3.12.0)
32+
rspec-core (3.12.2)
33+
rspec-support (~> 3.12.0)
34+
rspec-expectations (3.12.3)
3635
diff-lcs (>= 1.2.0, < 2.0)
37-
rspec-support (~> 3.3.0)
38-
rspec-mocks (3.3.2)
36+
rspec-support (~> 3.12.0)
37+
rspec-mocks (3.12.6)
3938
diff-lcs (>= 1.2.0, < 2.0)
40-
rspec-support (~> 3.3.0)
41-
rspec-support (3.3.0)
42-
ruby_parser (3.11.0)
43-
sexp_processor (~> 4.9)
44-
sexp_processor (4.11.0)
45-
slop (3.6.0)
39+
rspec-support (~> 3.12.0)
40+
rspec-support (3.12.1)
41+
ruby_parser (3.20.3)
42+
sexp_processor (~> 4.16)
43+
sexp_processor (4.17.0)
4644

4745
PLATFORMS
4846
ruby
4947

5048
DEPENDENCIES
5149
codeclimate-parser-client!
5250
concurrent-ruby (~> 1.0.0)
53-
flay (~> 2.12)
51+
flay (~> 2.13.1)
5452
pry
5553
rake
5654
rspec
57-
sexp_processor (~> 4.11)
55+
sexp_processor (~> 4.17)
5856

5957
BUNDLED WITH
6058
2.4.22

‎lib/cc/engine/analyzers/analyzer_base.rb‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
# frozen_string_literal: true
22

3+
# Monkey patch for Parser class
4+
# used in language analyzers via Sexp::Matcher.parse
5+
# https://github.com/seattlerb/sexp_processor/blob/master/lib/sexp_matcher.rb
6+
class Sexp
7+
class Matcher < Sexp
8+
class Parser
9+
def parse_sexp
10+
token = next_token
11+
12+
case token
13+
when "(" then
14+
parse_list
15+
when "[" then
16+
parse_cmd
17+
when "nil" then
18+
nil
19+
when /^\d+$/ then
20+
token.to_i
21+
when "___" then
22+
Sexp.___
23+
when "_" then
24+
Sexp._
25+
when %r%^/(.*)/$% then
26+
re = 1ドル
27+
raise SyntaxError, "Not allowed: /%p/" % [re] unless
28+
re =~ /\A([\w()|.*+^$]+)\z/
29+
Regexp.new re
30+
when /^"(.*)"$/ then
31+
1ドル
32+
when /^([A-Z]\w*)$/ then
33+
if Object.const_defined?(1ドル)
34+
Object.const_get 1ドル
35+
else
36+
# Handle as a symbol or string
37+
1ドル.to_sym # or return 1ドル as a string
38+
end
39+
when /^:?([\w?!=~-]+)$/ then
40+
1ドル.to_sym
41+
else
42+
raise SyntaxError, "unhandled token: %p" % [token]
43+
end
44+
end
45+
end
46+
end
47+
end
48+
349
require "cc/engine/analyzers/parser_error"
450
require "cc/engine/analyzers/parser_base"
551
require "cc/engine/analyzers/file_list"

‎spec/cc/engine/analyzers/ruby/main_spec.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ def self.from_remediation_amount(amount)
6161

6262
expect(json["location"]).to eq({
6363
"path" => "foo.rb",
64-
"lines" => { "begin" => 2, "end" => 12 },
64+
"lines" => { "begin" => 2, "end" => 11 },
6565
})
6666
expect(json["other_locations"]).to eq([
67-
{"path" => "foo.rb", "lines" => { "begin" => 18, "end" => 28} },
67+
{"path" => "foo.rb", "lines" => { "begin" => 18, "end" => 27} },
6868
])
6969
end
7070

‎spec/cc/engine/analyzers/sexp_lines_spec.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ module CC::Engine::Analyzers
1818

1919
expect(locations.count).to eq 2
2020
expect(locations[0].begin_line).to eq(3)
21-
expect(locations[0].end_line).to eq(7)
21+
expect(locations[0].end_line).to eq(4)
2222
expect(locations[1].begin_line).to eq(5)
23-
expect(locations[1].end_line).to eq(7)
23+
expect(locations[1].end_line).to eq(6)
2424
end
2525

2626
it "gets appropriate locations for hashes" do

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /