Skip to content

Commit

Permalink
Update rubocop and fix issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
arscan committed Mar 30, 2021
1 parent d43fe0a commit d847879
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 52 deletions.
8 changes: 7 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ AllCops:
- 'tmp/**/*'
- '*.gemspec'
- 'bin/*'
Metrics/LineLength:
Layout/LineLength:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
inherit_mode:
merge:
- Exclude
38 changes: 13 additions & 25 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-07-01 12:11:28 -0400 using RuboCop version 0.67.2.
# on 2021-03-30 16:14:38 -0400 using RuboCop version 0.80.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -45,15 +45,15 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 78

# Offense count: 10
# Offense count: 12
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 5

# Offense count: 7
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 358
Max: 356

# Offense count: 23
Metrics/CyclomaticComplexity:
Expand All @@ -62,7 +62,7 @@ Metrics/CyclomaticComplexity:
# Offense count: 44
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 135
Max: 133

# Offense count: 2
# Configuration parameters: CountComments.
Expand All @@ -73,30 +73,19 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Max: 68

# Offense count: 1
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'lib/fhir_models/bootstrap/hashable.rb'

# Offense count: 4
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
Naming/MethodParameterName:
Exclude:
- 'lib/fhir_models/fhir_ext/structure_definition_compare.rb'

# Offense count: 3
Performance/Caller:
Exclude:
- 'lib/fhir_models/bootstrap/model.rb'
- 'lib/fhir_models/deprecate.rb'

# Offense count: 1
# Offense count: 2
# Cop supports --auto-correct.
Performance/InefficientHashSearch:
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'lib/fhir_models/bootstrap/template.rb'
- 'lib/fhir_models/bootstrap/hashable.rb'

# Offense count: 1
# Configuration parameters: .
Expand Down Expand Up @@ -141,7 +130,6 @@ Style/Documentation:
Style/IfUnlessModifier:
Exclude:
- 'lib/fhir_models/bootstrap/generator.rb'
- 'lib/fhir_models/bootstrap/hashable.rb'
- 'lib/fhir_models/bootstrap/model.rb'
- 'lib/fhir_models/bootstrap/template.rb'
- 'lib/fhir_models/bootstrap/xml.rb'
Expand Down Expand Up @@ -175,7 +163,7 @@ Style/NumericPredicate:
- 'spec/**/*'
- 'lib/fhir_models/fhir_ext/structure_definition_compare.rb'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
Style/OrAssignment:
Exclude:
Expand All @@ -200,8 +188,8 @@ Style/RescueStandardError:

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
# Whitelist: present?, blank?, presence, try, try!
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'lib/fhir_models/bootstrap/definitions.rb'
Expand Down
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.1)
ast (2.4.2)
bcp47 (0.3.3)
i18n
coderay (1.1.3)
Expand Down Expand Up @@ -62,22 +62,22 @@ GEM
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
parallel (1.20.0)
parser (2.7.2.0)
parallel (1.20.1)
parser (3.0.0.0)
ast (~> 2.4.1)
power_assert (1.2.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-coolline (0.2.5)
coolline (~> 0.5)
psych (3.2.0)
racc (1.5.2)
rainbow (3.0.0)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.4)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
Expand All @@ -91,15 +91,15 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.0)
rubocop (0.67.0)
rubocop (0.80.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
psych (>= 3.1.0)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.6)
ruby-progressbar (1.10.1)
unicode-display_width (>= 1.4.0, < 1.7)
ruby-progressbar (1.11.0)
shellany (0.0.1)
simplecov (0.17.1)
docile (~> 1.1)
Expand All @@ -110,7 +110,7 @@ GEM
test-unit (3.3.6)
power_assert
thor (1.0.1)
unicode-display_width (1.5.0)
unicode-display_width (1.6.1)
unicode_utils (1.4.0)

PLATFORMS
Expand All @@ -126,7 +126,7 @@ DEPENDENCIES
pry-coolline
rake
rspec
rubocop (= 0.67)
rubocop (= 0.80)
simplecov (~> 0.17.0)
test-unit

Expand Down
2 changes: 1 addition & 1 deletion fhir_models.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'simplecov', '~> 0.17.0'
spec.add_development_dependency 'nokogiri-diff'
spec.add_development_dependency 'rubocop', '0.67'
spec.add_development_dependency 'rubocop', '0.80'
spec.add_development_dependency 'guard-rspec'
spec.add_development_dependency 'guard-test'
end
12 changes: 6 additions & 6 deletions lib/fhir_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
require File.join(root, 'lib', 'fhir_models', 'bootstrap', 'hashable.rb')
require File.join(root, 'lib', 'fhir_models', 'bootstrap', 'json.rb')

Dir.glob(File.join(root, 'lib', 'fhir_models', 'bootstrap', '*.rb')).each do |file|
Dir.glob(File.join(root, 'lib', 'fhir_models', 'bootstrap', '*.rb')).sort.each do |file|
require file
end
Dir.glob(File.join(root, 'lib', 'fhir_models', 'bootstrap', '**', '*.rb')).each do |file|
Dir.glob(File.join(root, 'lib', 'fhir_models', 'bootstrap', '**', '*.rb')).sort.each do |file|
require file
end

require File.join(root, 'lib', 'fhir_models', 'fhir.rb')

# Require the generated code
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhir', '*.rb')).each do |file|
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhir', '*.rb')).sort.each do |file|
require file
end
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhir', '**', '*.rb')).each do |file|
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhir', '**', '*.rb')).sort.each do |file|
require file
end

# Require the FHIRPath code
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhirpath', '*.rb')).each do |file|
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhirpath', '*.rb')).sort.each do |file|
require file
end

# Require the fhir_ext code
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhir_ext', '*.rb')).each do |file|
Dir.glob(File.join(root, 'lib', 'fhir_models', 'fhir_ext', '*.rb')).sort.each do |file|
require file
end
4 changes: 2 additions & 2 deletions lib/fhir_models/bootstrap/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def self.from_json(json)
resource_type = hash['resourceType']
klass = Module.const_get("FHIR::#{resource_type}")
resource = klass.new(hash)
rescue => ex
FHIR.logger.error("Failed to deserialize JSON:\n#{ex.backtrace}")
rescue => e
FHIR.logger.error("Failed to deserialize JSON:\n#{e.backtrace}")
FHIR.logger.debug("JSON:\n#{json}")
resource = nil
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fhir_models/bootstrap/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def self.from_xml(xml)
resource_type = doc.root.name
klass = Module.const_get("FHIR::#{resource_type}")
resource = klass.new(hash)
rescue => ex
FHIR.logger.error("Failed to deserialize XML:\n#{ex.backtrace}")
rescue => e
FHIR.logger.error("Failed to deserialize XML:\n#{e.backtrace}")
FHIR.logger.debug("XML:\n#{xml}")
resource = nil
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fhir_models/fhir_ext/structure_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def valid_json?(json)
if json.is_a? String
begin
json = JSON.parse(json)
rescue => ex
@errors << "Failed to parse JSON: #{ex.message} %n #{h} %n #{ex.backtrace.join("\n")}"
rescue => e
@errors << "Failed to parse JSON: #{e.message} %n #{h} %n #{e.backtrace.join("\n")}"
return false
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fhir_models/fhir_ext/structure_definition_finding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def from_json(json)
hash.each do |key, value|
obj.send("#{key}=".to_sym, value) if value
end
rescue => ex
FHIR.logger.error "Failed to parse JSON: #{ex.message}"
rescue => e
FHIR.logger.error "Failed to parse JSON: #{e.message}"
return nil
end
end
Expand Down

0 comments on commit d847879

Please sign in to comment.