app/helpers/documents_helper.rb

Summary

Maintainability
A
25 mins
Test Coverage

Method render_destroy_document_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def render_destroy_document_link(builder, document)
    if !document.persisted? && document.cached_attachment.present?
      link_to t('documents.form.delete_button'),
                  direct_upload_destroy_url("direct_upload[resource_type]": document.documentable_type,
                                            "direct_upload[resource_id]": document.documentable_id,
Severity: Minor
Found in app/helpers/documents_helper.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Line is too long. [113/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
Open

                               accept: accepted_content_types_extensions(document.documentable_type.constantize),
Severity: Minor
Found in app/helpers/documents_helper.rb by rubocop

Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
Open

                  direct_upload_destroy_url("direct_upload[resource_type]": document.documentable_type,
Severity: Minor
Found in app/helpers/documents_helper.rb by rubocop

Line is too long. [108/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
Open

                                            "direct_upload[cached_attachment]": document.cached_attachment),
Severity: Minor
Found in app/helpers/documents_helper.rb by rubocop

Line is too long. [168/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
Open

      link_to_remove_association document.new_record? ? t('documents.form.cancel_button') : t('documents.form.delete_button') , builder, class: "delete remove-document"
Severity: Minor
Found in app/helpers/documents_helper.rb by rubocop

There are no issues that match your filters.

Category
Status