Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalker2398 committed Feb 16, 2024
1 parent 2043250 commit 38d5771
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 93 deletions.
77 changes: 9 additions & 68 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 10000`
# on 2024-01-09 21:03:14 UTC using RuboCop version 1.59.0.
# on 2024-02-16 22:15:49 UTC using RuboCop version 1.59.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
# versions of RuboCop, may require this file to be generated again.

# Offense count: 6
# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterGuardClause:
Exclude:
- 'app/controllers/api_controller.rb'
- 'app/models/resource.rb'
- 'lib/triclops/raster.rb'

# Offense count: 6
# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Expand All @@ -24,7 +24,7 @@ Layout/IndentationConsistency:
- 'app/controllers/api_controller.rb'
- 'app/controllers/application_controller.rb'

# Offense count: 6
# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, AllowedPatterns.
Layout/IndentationWidth:
Expand All @@ -33,22 +33,10 @@ Layout/IndentationWidth:
- 'app/controllers/api_controller.rb'
- 'app/controllers/application_controller.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/SpaceAfterComma:
Exclude:
- 'app/models/user.rb'

# Offense count: 1
# Configuration parameters: AllowKeywordBlockArguments.
Lint/UnderscorePrefixedVariableName:
Exclude:
- 'app/models/user.rb'

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 32
Max: 43

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
Expand All @@ -59,27 +47,12 @@ Metrics/BlockLength:
# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 19
Max: 12

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 9

# Offense count: 1
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'app/models/user.rb'
Max: 12

# Offense count: 21
# This cop supports safe autocorrection (--autocorrect).
Expand Down Expand Up @@ -159,21 +132,6 @@ Rails/IndexWith:
Exclude:
- 'app/models/concerns/triclops/resource/as_json.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/UniqueValidationWithoutIndex:
Exclude:
- 'app/models/user.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'app/models/user.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Keywords, RequireColon.
Expand All @@ -182,14 +140,6 @@ Style/CommentAnnotation:
Exclude:
- 'spec/requests/iiif/images/raster_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'app/models/user.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/ExpandPathArguments:
Expand All @@ -202,14 +152,6 @@ Style/ExplicitBlockArgument:
Exclude:
- 'lib/triclops/lock.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'app/models/user.rb'
- 'config/routes.rb'
- 'lib/triclops/raster.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
Expand All @@ -225,13 +167,12 @@ Style/RedundantFetchBlock:
Exclude:
- 'config/puma.rb'

# Offense count: 7
# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'app/models/resource.rb'
- 'app/models/user.rb'
- 'spec/models/concerns/triclops/resource/iiif_info_spec.rb'
- 'spec/models/resource_spec.rb'

Expand Down Expand Up @@ -260,7 +201,7 @@ Style/StringLiterals:
- 'spec/triclops/raster_cache_spec.rb'
- 'spec/triclops/raster_spec.rb'

# Offense count: 15
# Offense count: 17
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/api/v1/resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def index
status = statuses.include?(param_status) ? statuses.index(param_status) : param_status
page = index_params[:page] ? Integer(index_params[:page]) : 1
identifier = index_params[:identifier]
last_page = false

resources = Resource
identifier && resources = resources.where(identifier: identifier)
Expand All @@ -64,11 +63,8 @@ def index
resources = resources.limit(per_page).offset((page - 1) * per_page)
status && status != 'any' && resources = resources.order(:status)

puts last_page
render json:
{ resources: resources.map(&:attributes),
last_page: last_page
}
{ resources: resources.map(&:attributes), last_page: last_page }
end

private
Expand Down
40 changes: 20 additions & 20 deletions spec/requests/api/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
end
get_with_auth '/api/v1/resources'
expect(response).to have_http_status(:success)
expected_response_json =
{
'resources' => resources.map do |resource| {
'accessed_at' => nil,
'created_at' => resource.created_at.to_time.iso8601(3),
'error_message' => nil,
'featured_region' => resource.featured_region,
'height' => resource.height,
'id' => resources.index(resource) + 1,
'identifier' => resource.identifier,
'pcdm_type' => 'Image',
'source_uri' => resource.source_uri,
'status' => 'pending',
'updated_at' => resource.updated_at.to_time.iso8601(3),
'width' => resource.width
}
expected_response_json = {
'resources' => resources.map do |resource|
{
'accessed_at' => nil,
'created_at' => resource.created_at.to_time.iso8601(3),
'error_message' => nil,
'featured_region' => resource.featured_region,
'height' => resource.height,
'id' => resources.index(resource) + 1,
'identifier' => resource.identifier,
'pcdm_type' => 'Image',
'source_uri' => resource.source_uri,
'status' => 'pending',
'updated_at' => resource.updated_at.to_time.iso8601(3),
'width' => resource.width
}
end,
'last_page' => true
}
Expand All @@ -53,7 +53,7 @@
resource = resources[1]
expected_response_json =
{
'resources' => [{
'resources' => [{
'accessed_at' => nil,
'created_at' => resource.created_at.to_time.iso8601(3),
'error_message' => nil,
Expand All @@ -77,13 +77,13 @@
FactoryBot.create(:resource, identifier: identifiers[0]),
FactoryBot.create(:resource, :ready, identifier: identifiers[1])
]
get_with_auth "/api/v1/resources?status=ready"
get_with_auth '/api/v1/resources?status=ready'
# puts "/api/v1/resources/identifier=#{identifiers[1]}"
expect(response).to have_http_status(:success)
resource = resources[1]
expected_response_json =
{
'resources' => [{
'resources' => [{
'accessed_at' => nil,
'created_at' => resource.created_at.to_time.iso8601(3),
'error_message' => nil,
Expand All @@ -106,7 +106,7 @@
resources = identifiers.map do |identifier|
FactoryBot.create(:resource, identifier: identifier)
end
get_with_auth "/api/v1/resources?per_page=1&page=2"
get_with_auth '/api/v1/resources?per_page=1&page=2'
# puts "/api/v1/resources/identifier=#{identifiers[1]}"
expect(response).to have_http_status(:success)
resource = resources[1]
Expand Down

0 comments on commit 38d5771

Please sign in to comment.