Skip to content

Conversation

@EnkiP
Copy link
Member

@EnkiP EnkiP commented Oct 24, 2025

Definition of Done

General

  • Write an explicit title for the Pull Request, following Conventional Commits specification
  • Test manually the implemented changes
  • Validate the code quality (indentation, syntax, style, simplicity, readability)

Security

  • Consider the security impact of the changes made

@qltysh
Copy link

qltysh bot commented Oct 24, 2025

4 new issues

Tool Category Rule Count
qlty Structure Function with many returns (count = 4): get_error_message 2
qlty Structure Function with many parameters (count = 5): initialize 1
qlty Structure Function with high complexity (count = 6): translate 1

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

class HttpError < StandardError
attr_reader :status, :user_message, :custom_headers, :meta, :cause, :name

def initialize(error, status, user_message = nil, _meta = nil, custom_headers_proc = nil)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with many parameters (count = 5): initialize [qlty:function-parameters]

Enki Pontvianne added 2 commits October 24, 2025 13:09
@qltysh
Copy link

qltysh bot commented Oct 24, 2025

Diff Coverage: The code coverage on the diff in this pull request is 83.0%.

Total Coverage: This PR will decrease coverage by 0.18%.

File Coverage Changes
Path File Coverage Δ Indirect
packages/forest_admin_agent/lib/forest_admin_agent/builder/agent_factory.rb 0.2
packages/forest_admin_agent/lib/forest_admin_agent/http/Exceptions/conflict_error.rb -100.0
packages/forest_admin_agent/lib/forest_admin_agent/http/Exceptions/forbidden_error.rb -100.0
packages/forest_admin_agent/lib/forest_admin_agent/http/Exceptions/http_error.rb 95.5
packages/forest_admin_agent/lib/forest_admin_agent/http/Exceptions/not_found_error.rb -100.0
packages/forest_admin_agent/lib/forest_admin_agent/http/Exceptions/require_approval.rb -100.0
packages/forest_admin_agent/lib/forest_admin_agent/http/Exceptions/unprocessable_error.rb -100.0
packages/forest_admin_agent/lib/forest_admin_agent/http/Exceptions/validation_error.rb -100.0
packages/forest_admin_agent/lib/forest_admin_agent/http/error_handling.rb -16.7
packages/forest_admin_agent/lib/forest_admin_agent/http/error_translator.rb 65.6
packages/forest_admin_agent/lib/forest_admin_agent/routes/resources/native_query.rb 0.0
packages/forest_admin_agent/lib/forest_admin_agent/services/permissions.rb -0.4
packages/forest_admin_agent/lib/forest_admin_agent/services/smart_action_checker.rb 0.6
packages/forest_admin_agent/lib/forest_admin_agent/services/sse_cache_invalidation.rb 0.8
packages/forest_admin_agent/lib/forest_admin_agent/utils/caller_parser.rb 0.3
packages/forest_admin_agent/lib/forest_admin_agent/utils/query_string_parser.rb 0.0
packages/forest_admin_datasource_customizer/lib/forest_admin_datasource_customizer/decorators/relation/relation_collection_decorator.rb 0.0
packages/forest_admin_datasource_customizer/lib/forest_admin_datasource_customizer/decorators/validation/validation_collection_decorator.rb 0.1
packages/forest_admin_datasource_customizer/lib/forest_admin_datasource_customizer/decorators/write/write_replace/write_replace_collection_decorator.rb 0.0
packages/forest_admin_datasource_mongoid/lib/forest_admin_datasource_mongoid/utils/schema/mongoid_schema.rb -0.9
🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

Comment on lines 12 to 27
def get_error_message(error)
return error.user_message if error.is_a?(ForestAdminAgent::Http::Exceptions::HttpError)

if error.class.respond_to?(:ancestors) && error.class.ancestors.include?(ForestAdminAgent::Http::Exceptions::HttpException)
return error.message
end

if (customizer = ForestAdminAgent::Facades::Container.cache(:customize_error_message))
return error.message if error.is_a?(ForestAdminAgent::Http::Exceptions::BusinessError)

if defined?(ForestAdminAgent::Facades) &&
(customizer = ForestAdminAgent::Facades::Container.cache(:customize_error_message))
message = eval(customizer).call(error)
return message if message
end

return error.message if error.is_a?(ForestAdminDatasourceToolkit::Exceptions::ValidationError)

'Unexpected error'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with many returns (count = 4): get_error_message [qlty:return-statements]

Comment on lines +37 to +71
def self.translate(error) # rubocop:disable Metrics/MethodLength
# Already an HttpError or HttpException - no translation needed
return error if error.is_a?(Exceptions::HttpError)
return error if error.respond_to?(:status) && error.status

# Translate DatasourceToolkit ValidationError to Agent BadRequestError
if defined?(ForestAdminDatasourceToolkit::Exceptions::ValidationError) &&
error.is_a?(ForestAdminDatasourceToolkit::Exceptions::ValidationError)
error = Exceptions::BadRequestError.new(error.message)
end

# Translate BusinessError to HttpError with appropriate status code
case error
when Exceptions::BadRequestError, Exceptions::ValidationError
ERROR_400.new(error)
when Exceptions::ForbiddenError
ERROR_403.new(error)
when Exceptions::NotFoundError
ERROR_404.new(error)
when Exceptions::ConflictError
ERROR_409.new(error)
when Exceptions::UnprocessableError
ERROR_422.new(error)
when Exceptions::TooManyRequestsError
ERROR_429.new(error)
when Exceptions::InternalServerError
ERROR_500.new(error)
when Exceptions::BadGatewayError
ERROR_502.new(error)
when Exceptions::ServiceUnavailableError
ERROR_503.new(error)
else
# Unknown error type - return as-is, will be handled as 500
error
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with high complexity (count = 6): translate [qlty:function-complexity]

@EnkiP
Copy link
Member Author

EnkiP commented Oct 29, 2025

closed in favor of #197

@EnkiP EnkiP closed this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants