Skip to content

Commit 2271be6

Browse files
authored
Merge pull request #167 from samvera/bixby
Address dependency vulnerability for rubocop by updating to use bixby
2 parents a30fc63 + 1b46242 commit 2271be6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+349
-340
lines changed

.rubocop.yml

+19-115
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,26 @@
1-
inherit_from: .rubocop_todo.yml
2-
3-
AllCops:
4-
DisplayCopNames: true
5-
Include:
6-
- '**/Rakefile'
7-
8-
Metrics/LineLength:
9-
Enabled: false
10-
11-
Metrics/AbcSize:
12-
Enabled: false
13-
14-
Metrics/MethodLength:
15-
Enabled: false
16-
17-
Style/BlockDelimiters:
18-
Exclude:
19-
- 'spec/**/*'
20-
21-
Style/BlockEndNewline:
22-
Exclude:
23-
- 'spec/**/*'
24-
25-
Style/MultilineBlockLayout:
26-
Exclude:
27-
- 'spec/**/*'
28-
29-
Style/IndentationConsistency:
30-
EnforcedStyle: rails
31-
32-
Style/CollectionMethods:
33-
PreferredMethods:
34-
collect: 'map'
35-
collect!: 'map!'
36-
inject: 'reduce'
37-
detect: 'find'
38-
find_all: 'select'
39-
40-
Style/WordArray:
41-
Enabled: false
42-
43-
Style/RegexpLiteral:
44-
Enabled: false
45-
46-
Style/StringLiterals:
47-
Enabled: false
48-
49-
Style/ClassAndModuleChildren:
50-
Enabled: false
51-
52-
Style/Documentation:
53-
Enabled: false
54-
55-
Style/HashSyntax:
56-
Exclude:
57-
58-
Style/LineEndConcatenation:
59-
Exclude:
1+
inherit_gem:
2+
bixby: bixby_default.yml
603

61-
Style/PredicateName:
62-
Exclude:
63-
64-
Style/GlobalVars:
65-
Exclude:
66-
- 'spec/**/*'
67-
68-
Style/SingleLineBlockParams:
69-
Enabled: false
70-
71-
Style/ClassVars:
72-
Exclude:
4+
inherit_from: .rubocop_todo.yml
735

74-
Style/SignalException:
6+
# By default RSpec/MessageSpies has the following:
7+
# Prefer have_received for setting message expectations. Setup form as a spy using allow or instance_spy.
8+
# The default assumes EnforcedStyle is 'have_received'. Most of our specs are 'receive'
9+
RSpec/MessageSpies:
7510
Enabled: false
7611

77-
Style/FileName:
12+
Metrics/BlockLength:
13+
ExcludedMethods: ['included']
7814
Exclude:
15+
- 'qa.gemspec'
16+
- 'spec/**/*.rb'
7917

80-
Style/VariableName:
81-
Exclude:
82-
- 'lib/share_notify/push_document.rb'
83-
84-
Style/FrozenStringLiteralComment:
85-
Enabled: false
86-
87-
RSpec/ExampleWording:
88-
CustomTransform:
89-
be: is
90-
have: has
91-
not: does not
92-
NOT: does NOT
93-
IgnoredWords:
94-
- only
95-
96-
RSpec/ExpectActual:
97-
Enabled: false
98-
99-
RSpec/FilePath:
100-
Enabled: false
101-
102-
RSpec/InstanceVariable:
103-
Enabled: false
104-
105-
RSpec/DescribeClass:
18+
AllCops:
19+
TargetRubyVersion: 2.1
20+
DisplayCopNames: true
10621
Exclude:
107-
- 'spec/lib/tasks/mesh.rake_spec.rb'
108-
109-
RSpec/LetSetup:
110-
Enabled: false
111-
112-
RSpec/MessageExpectation:
113-
Enabled: false
114-
115-
RSpec/MultipleExpectations:
116-
Enabled: false
117-
118-
RSpec/NestedGroups:
119-
Enabled: false
120-
121-
RSpec/LeadingSubject:
122-
Enabled: false
22+
- 'db/**/*'
23+
- 'script/**/*'
24+
- 'vendor/**/*'
25+
Include:
26+
- '**/Rakefile'

.rubocop_todo.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
require: rubocop-rspec
22

3-
Metrics/CyclomaticComplexity:
3+
RSpec/NamedSubject:
4+
Enabled: false
5+
6+
RSpec/ExampleLength:
7+
Max: 9
48
Exclude:
5-
- 'lib/qa/authorities/mesh_tools/mesh_data_parser.rb'
9+
- 'spec/**/*.rb'
610

711
Metrics/ClassLength:
812
Exclude:
@@ -11,11 +15,6 @@ Metrics/ClassLength:
1115
- 'lib/qa/authorities/linked_data/search_query.rb'
1216
- 'lib/qa/authorities/linked_data/config/term_config.rb'
1317

14-
RSpec/ExampleLength:
15-
Max: 7
18+
Metrics/CyclomaticComplexity:
1619
Exclude:
17-
- 'spec/lib/mesh_data_parser_spec.rb'
18-
- 'spec/lib/authorities/mesh_spec.rb'
19-
20-
RSpec/NamedSubject:
21-
Enabled: false
20+
- 'lib/qa/authorities/mesh_tools/mesh_data_parser.rb'

Gemfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ source "https://rubygems.org"
33
gemspec path: File.expand_path('..', __FILE__)
44

55
group :development, :test do
6-
gem 'simplecov', require: false
76
gem 'coveralls', require: false
7+
gem 'simplecov', require: false
88
end
99

1010
# BEGIN ENGINE_CART BLOCK
1111
# engine_cart: 0.10.0
1212
# engine_cart stanza: 0.10.0
1313
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
14-
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__
15-
)))
14+
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))
1615
if File.exist?(file)
1716
begin
1817
eval_gemfile file
@@ -23,6 +22,7 @@ if File.exist?(file)
2322
else
2423
Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
2524

25+
# rubocop:disable Bundler/DuplicatedGem
2626
if ENV['RAILS_VERSION']
2727
if ENV['RAILS_VERSION'] == 'edge'
2828
gem 'rails', github: 'rails/rails'
@@ -34,11 +34,12 @@ else
3434

3535
case ENV['RAILS_VERSION']
3636
when /^4.2/
37+
gem 'coffee-rails', '~> 4.1.0'
3738
gem 'responders', '~> 2.0'
3839
gem 'sass-rails', '>= 5.0'
39-
gem 'coffee-rails', '~> 4.1.0'
4040
when /^4.[01]/
4141
gem 'sass-rails', '< 5.0'
4242
end
43+
# rubocop:enable Bundler/DuplicatedGem
4344
end
4445
# END ENGINE_CART BLOCK

app/controllers/qa/linked_data_terms_controller.rb

+11-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def index
1414

1515
# Return a list of terms based on a query
1616
# @see Qa::Authorities::LinkedData::SearchQuery#search
17-
def search
17+
def search # rubocop:disable Metrics/MethodLength
1818
begin
1919
terms = @authority.search(query, subauth: subauthority, language: language, replacements: replacement_params)
2020
rescue Qa::ServiceUnavailable
@@ -26,7 +26,8 @@ def search
2626
head :internal_server_error
2727
return
2828
rescue RDF::FormatError
29-
logger.warn "RDF Format Error - Results from search query #{query} for#{subauth_warn_msg} authority #{vocab_param} was not identified as a valid RDF format. You may need to include the linkeddata gem."
29+
logger.warn "RDF Format Error - Results from search query #{query} for#{subauth_warn_msg} authority #{vocab_param} " \
30+
"was not identified as a valid RDF format. You may need to include the linkeddata gem."
3031
head :internal_server_error
3132
return
3233
end
@@ -35,7 +36,7 @@ def search
3536

3637
# Return all the information for a given term
3738
# @see Qa::Authorities::LinkedData::FindTerm#find
38-
def show
39+
def show # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
3940
begin
4041
term = @authority.find(id, subauth: subauthority, language: language, replacements: replacement_params)
4142
rescue Qa::TermNotFound
@@ -51,7 +52,8 @@ def show
5152
head :internal_server_error
5253
return
5354
rescue RDF::FormatError
54-
logger.warn "RDF Format Error - Results from fetch term #{id} for#{subauth_warn_msg} authority #{vocab_param} was not identified as a valid RDF format. You may need to include the linkeddata gem."
55+
logger.warn "RDF Format Error - Results from fetch term #{id} for#{subauth_warn_msg} authority #{vocab_param} " \
56+
"was not identified as a valid RDF format. You may need to include the linkeddata gem."
5557
head :internal_server_error
5658
return
5759
end
@@ -61,23 +63,23 @@ def show
6163
private
6264

6365
def check_authority
64-
if params[:vocab].nil? || !params[:vocab].size.positive?
66+
if params[:vocab].nil? || !params[:vocab].size.positive? # rubocop:disable Style/GuardClause
6567
logger.warn "Required param 'vocab' is missing or empty"
6668
head :bad_request
6769
end
6870
end
6971

7072
def check_search_subauthority
7173
return if subauthority.nil?
72-
unless @authority.search_subauthority?(subauthority)
74+
unless @authority.search_subauthority?(subauthority) # rubocop:disable Style/GuardClause
7375
logger.warn "Unable to initialize linked data search sub-authority '#{subauthority}' for authority '#{vocab_param}'"
7476
head :bad_request
7577
end
7678
end
7779

7880
def check_show_subauthority
7981
return if subauthority.nil?
80-
unless @authority.term_subauthority?(subauthority)
82+
unless @authority.term_subauthority?(subauthority) # rubocop:disable Style/GuardClause
8183
logger.warn "Unable to initialize linked data term sub-authority '#{subauthority}' for authority '#{vocab_param}'"
8284
head :bad_request
8385
end
@@ -95,7 +97,7 @@ def vocab_param
9597
end
9698

9799
def check_query_param
98-
if params[:q].nil? || !params[:q].size.positive?
100+
if params[:q].nil? || !params[:q].size.positive? # rubocop:disable Style/GuardClause
99101
logger.warn "Required search param 'q' is missing or empty"
100102
head :bad_request
101103
end
@@ -107,7 +109,7 @@ def query
107109
end
108110

109111
def check_id_param
110-
if params[:id].nil? || !params[:id].size.positive?
112+
if params[:id].nil? || !params[:id].size.positive? # rubocop:disable Style/GuardClause
111113
logger.warn "Required show param 'id' is missing or empty"
112114
head :bad_request
113115
end

app/controllers/qa/terms_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def check_vocab_param
3232
head :not_found unless params[:vocab].present?
3333
end
3434

35-
def init_authority
35+
def init_authority # rubocop:disable Metrics/MethodLength
3636
begin
3737
mod = authority_class.camelize.constantize
3838
rescue NameError

app/models/qa/mesh_tree.rb

+5-9
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ def self.classify_all_trees
66
end
77

88
def eval_tree_path
9-
trees = read_attribute(:eval_tree_path) || write_attribute(:eval_tree_path, "")
10-
if trees
11-
trees.split("|")
12-
else
13-
[]
14-
end
9+
trees = self[:eval_tree_path] || (self[:eval_tree_path] = "")
10+
trees ? trees.split("|") : []
1511
end
1612

1713
def classify_tree
@@ -20,10 +16,10 @@ def classify_tree
2016
end
2117

2218
def classify_tree!
23-
unless classify_tree.empty?
19+
unless classify_tree.empty? # rubocop:disable Style/GuardClause
2420
tree_path = classify_tree.join('|')
25-
puts "After Join #{tree_path.inspect}"
26-
update_attribute(:eval_tree_path, tree_path)
21+
Rails.logger.info "After Join #{tree_path.inspect}"
22+
update_attribute(:eval_tree_path, tree_path) # rubocop:disable Rails/SkipsModelValidations # TODO: Explore how to avoid use of update_attribute.
2723
end
2824
end
2925

app/models/qa/subject_mesh_term.rb

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ def trees
1010
end
1111

1212
def synonyms
13-
s = read_attribute(:synonyms)
13+
s = self[:synonyms]
1414
s.nil? ? [] : s.split("|")
1515
end
1616

1717
def synonyms=(syn_list)
18-
write_attribute(:synonyms,
19-
if syn_list.respond_to?(:join)
20-
syn_list.join('|')
21-
else
22-
syn_list
23-
end)
18+
self[:synonyms] = syn_list.respond_to?(:join) ? syn_list.join('|') : syn_list
2419
end
2520

2621
def parents

config/initializers/linked_data_authorities.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
end
99

1010
# load app configured linked data authorities and overrides
11-
Dir[File.join(Rails.root, 'config', 'authorities', 'linked_data', '*.json')].each do |fn|
11+
Dir[Rails.root.join('config', 'authorities', 'linked_data', '*.json')].each do |fn|
1212
auth = File.basename(fn, '.json').upcase.to_sym
1313
json = File.read(File.expand_path(fn, __FILE__))
1414
cfg = JSON.parse(json).deep_symbolize_keys

lib/generators/qa/local/tables/mysql/mysql_generator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class MysqlGenerator < Rails::Generators::Base
55
source_root File.expand_path('../templates', __FILE__)
66
include ActiveRecord::Generators::Migration
77

8-
def migrations
8+
def migrations # rubocop:disable Metrics/MethodLength
99
unless defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
1010
message = "Use the table based generator if you are not using mysql 'rails generate qa:local:tables'"
1111
say_status("error", message, :red)

lib/generators/qa/local/tables/tables_generator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class TablesGenerator < Rails::Generators::Base
44
source_root File.expand_path('../templates', __FILE__)
55
include ActiveRecord::Generators::Migration
66

7-
def migrations
7+
def migrations # rubocop:disable Metrics/MethodLength
88
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
99
message = "Use the mysql table based generator if you are using mysql 'rails generate qa:local:tables:mysql'"
1010
say_status("error", message, :red)

0 commit comments

Comments
 (0)