Skip to content

Commit

Permalink
Update rubocop configs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Aug 10, 2020
1 parent ae7c9d3 commit 1a289b1
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 32 deletions.
105 changes: 105 additions & 0 deletions .rubocop.yml
Expand Up @@ -79,3 +79,108 @@ Style/RedundantRegexpEscape:

Style/SlicingWithRange:
Enabled: true

Lint/BinaryOperatorWithIdenticalOperands:
Enabled: true

Lint/DuplicateElsifCondition:
Enabled: true

Lint/DuplicateRescueException:
Enabled: true

Lint/EmptyConditionalBody:
Enabled: true

Lint/FloatComparison:
Enabled: true

Lint/MissingSuper:
Enabled: true

Lint/OutOfRangeRegexpRef:
Enabled: true

Lint/SelfAssignment:
Enabled: true

Lint/TopLevelReturnWithArgument:
Enabled: true

Lint/UnreachableLoop:
Enabled: true

Style/AccessorGrouping:
Enabled: true

Style/ArrayCoercion:
Enabled: true

Style/BisectedAttrAccessor:
Enabled: true

Style/CaseLikeIf:
Enabled: true

Style/ExplicitBlockArgument:
Enabled: true

Style/GlobalStdStream:
Enabled: true

Style/HashAsLastArrayItem:
Enabled: true

Style/HashLikeCase:
Enabled: true

Style/OptionalBooleanParameter:
Enabled: true

Style/RedundantAssignment:
Enabled: true

Style/RedundantFileExtensionInRequire:
Enabled: true

Style/SingleArgumentDig:
Enabled: true

Style/StringConcatenation:
Enabled: true

Rails/ActiveRecordCallbacksOrder:
Enabled: true

Rails/FindById:
Enabled: true

Rails/Inquiry:
Enabled: true

Rails/MailerName:
Enabled: true

Rails/MatchRoute:
Enabled: true

Rails/NegateInclude:
Enabled: true

Rails/Pluck:
Enabled: true

Rails/PluckInWhere:
Enabled: true

Rails/RenderInline:
Enabled: true

Rails/RenderPlainText:
Enabled: true

Rails/ShortI18n:
Enabled: true

Rails/WhereExists:
Enabled: true
47 changes: 37 additions & 10 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-06-29 18:27:34 UTC using RuboCop version 0.86.0.
# on 2020-08-10 14:27:02 UTC using RuboCop version 0.89.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 All @@ -23,30 +23,30 @@ Lint/SuppressedException:
Exclude:
- 'lib/tasks/rspec.rake'

# Offense count: 51
# Offense count: 46
# Configuration parameters: IgnoredMethods.
Metrics/AbcSize:
Max: 38

# Offense count: 3
# Configuration parameters: CountComments.
# Offense count: 4
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 118
Max: 119

# Offense count: 12
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 61
# Configuration parameters: CountComments, ExcludedMethods.
# Offense count: 62
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
Metrics/MethodLength:
Max: 43
Max: 44

# Offense count: 2
# Offense count: 6
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 10
Max: 12

# Offense count: 9
Naming/AccessorMethodName:
Expand Down Expand Up @@ -240,6 +240,12 @@ Style/ExpandPathArguments:
- 'bin/rake'
- 'spec/rails_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/ExplicitBlockArgument:
Exclude:
- 'app/services/published_relationships_filter.rb'

# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Expand Down Expand Up @@ -268,6 +274,12 @@ Style/NumericPredicate:
- 'app/models/dor/update_marc_record_service.rb'
- 'app/services/release_tags/identity_metadata.rb'

# Offense count: 2
Style/OptionalBooleanParameter:
Exclude:
- 'app/services/release_tags/identity_metadata.rb'
- 'app/services/version_service.rb'

# Offense count: 16
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Expand All @@ -282,6 +294,21 @@ Style/PercentLiteralDelimiters:
- 'config/spring.rb'
- 'spec/dor/update_marc_record_service_spec.rb'

# Offense count: 24
# Cop supports --auto-correct.
Style/StringConcatenation:
Exclude:
- 'app/controllers/content_controller.rb'
- 'app/services/dublin_core_service.rb'
- 'app/services/public_xml_service.rb'
- 'bin/console'
- 'spec/rails_helper.rb'
- 'spec/requests/create_workspaces_spec.rb'
- 'spec/services/cleanup_service_spec.rb'
- 'spec/services/public_desc_metadata_service_spec.rb'
- 'spec/services/public_xml_service_spec.rb'
- 'spec/services/reset_workspace_service_spec.rb'

# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
Expand Down
5 changes: 3 additions & 2 deletions app/models/symphony_reader.rb
Expand Up @@ -68,10 +68,11 @@ def fetch_marc_response
def symphony_response(url)
resp = client.get(url)

if resp.status == 200
case resp.status
when 200
validate_response(resp)
return resp
elsif resp.status == 404
when 404
# 404 received here is for the catkey, but this app cares about the druid
# for the DOR object, hence raising 404 from here could be misleading
errmsg = "Record not found in Symphony. API call: #{url}"
Expand Down
7 changes: 4 additions & 3 deletions app/services/cocina/mapper.rb
Expand Up @@ -25,11 +25,12 @@ def initialize(item)
# @raises [SolrConnectionError]
def build
klass = cocina_klass
props = if klass == Cocina::Models::DRO
props = case klass
when Cocina::Models::DRO
FromFedora::DRO.props(item)
elsif klass == Cocina::Models::Collection
when Cocina::Models::Collection
FromFedora::Collection.props(item)
elsif klass == Cocina::Models::AdminPolicy
when Cocina::Models::AdminPolicy
FromFedora::APO.props(item)
else
raise "unable to build '#{klass}'"
Expand Down
3 changes: 1 addition & 2 deletions app/services/sdr_ingest_service.rb
Expand Up @@ -112,8 +112,7 @@ def self.get_content_metadata(metadata_dir)
# @param [Pathname] metadata_dir The location of the the object's metadata files
# @return [Moab::FileGroup] Traverse the metadata directory and generate a metadata group
def self.get_metadata_file_group(metadata_dir)
file_group = Moab::FileGroup.new(group_id: 'metadata').group_from_directory(metadata_dir)
file_group
Moab::FileGroup.new(group_id: 'metadata').group_from_directory(metadata_dir)
end

# @param [Pathname] bag_dir the location of the bag to be verified
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Expand Up @@ -42,7 +42,7 @@
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Expand Up @@ -58,7 +58,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down
5 changes: 3 additions & 2 deletions spec/support/foxml_helper.rb
Expand Up @@ -33,9 +33,10 @@ def item_from_foxml(foxml, item_class = Dor::Abstract)
result.add_datastream(ds)
end

if ds.is_a?(ActiveFedora::OmDatastream)
case ds
when ActiveFedora::OmDatastream
result.datastreams[dsid] = ds.class.from_xml(Nokogiri::XML(content), ds)
elsif ds.is_a?(ActiveFedora::RelsExtDatastream)
when ActiveFedora::RelsExtDatastream
result.datastreams[dsid] = ds.class.from_xml(content, ds)
else
result.datastreams[dsid] = ds.class.from_xml(ds, stream)
Expand Down
22 changes: 11 additions & 11 deletions spec/validators/cocina/validate_dark_service_spec.rb
Expand Up @@ -29,17 +29,17 @@
version: 1,
structural: {
contains: [
externalIdentifier: 'bc123df4567_1',
label: 'Page 1',
type: 'http://cocina.sul.stanford.edu/models/file.jsonld',
version: 1,
access: { access: file_access },
administrative: {
shelve: shelve,
sdrPreserve: true
},
hasMessageDigests: [],
filename: 'page1.txt'
{ externalIdentifier: 'bc123df4567_1',
label: 'Page 1',
type: 'http://cocina.sul.stanford.edu/models/file.jsonld',
version: 1,
access: { access: file_access },
administrative: {
shelve: shelve,
sdrPreserve: true
},
hasMessageDigests: [],
filename: 'page1.txt' }
]
}
}
Expand Down

0 comments on commit 1a289b1

Please sign in to comment.