codez/dry_crud

View on GitHub

Showing 9 of 9 total issues

Class Builder has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Builder < ActionView::Helpers::FormBuilder

      class_attribute :control_class
      self.control_class = Control

Severity: Minor
Found in app/helpers/dry_crud/form/builder.rb - About 3 hrs to fix

    Class CrudController has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class CrudController < ListController
    
      class_attribute :permitted_attrs
    
      # Defines before and after callback hooks for create, update, save and
    Severity: Minor
    Found in app/controllers/crud_controller.rb - About 2 hrs to fix

      Method select_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def select_options(attr, **options)
              prompt = options.delete(:prompt)
              blank = options.delete(:include_blank)
              if options[:multiple]
                {}
      Severity: Minor
      Found in app/helpers/dry_crud/form/builder.rb - About 35 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

      Method detect_field_method has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def detect_field_method
              if type == :text
                :text_area
              elsif association_kind?(:belongs_to)
                :belongs_to_field
      Severity: Minor
      Found in app/helpers/dry_crud/form/control.rb - About 35 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def update(**options, &block)
          model_class.transaction do
            assign_attributes
            updated = with_callbacks(:update, :save) { entry.save }
            respond(updated,
      Severity: Minor
      Found in app/controllers/crud_controller.rb and 1 other location - About 30 mins to fix
      app/controllers/crud_controller.rb on lines 60..67

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        def create(**options, &block)
          model_class.transaction do
            assign_attributes
            created = with_callbacks(:create, :save) { entry.save }
            respond(created,
      Severity: Minor
      Found in app/controllers/crud_controller.rb and 1 other location - About 30 mins to fix
      app/controllers/crud_controller.rb on lines 83..90

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

            def edit_action_col(**html_options, &block)
              action_col do |entry|
                path = action_path(entry, &block)
                if path
                  path = edit_polymorphic_path(path) unless path.is_a?(String)
      Severity: Minor
      Found in app/helpers/dry_crud/table/actions.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

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

            def list_entries
              sortable = sortable?(params[:sort])
              if sortable || default_sort
                clause = [sortable ? sort_expression : nil, default_sort]
                super.reorder(Arel.sql(clause.compact.join(', ')))
      Severity: Minor
      Found in app/controllers/dry_crud/sortable.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

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

            def align_class(attr)
              entry = entries.present? ? entry_class.new : nil
              case column_type(entry, attr)
              when :integer, :float, :decimal
                'right' unless association(entry, attr, :belongs_to)
      Severity: Minor
      Found in app/helpers/dry_crud/table/builder.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

      Severity
      Category
      Status
      Source
      Language