lib/generators/avo/eject_generator.rb

Summary

Maintainability
C
1 day
Test Coverage

Method eject_component has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

        def eject_component(component_to_eject = options[:component], confirmation: true)
          # Underscore the component name
          # Example: Avo::Views::ResourceIndexComponent => avo/views/resource_index_component
          component = component_to_eject.underscore

Severity: Minor
Found in lib/generators/avo/eject_generator.rb - About 3 hrs 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 eject_partial has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

        def eject_partial
          if options[:partial].starts_with?(":")
            template_id = path_to_sym options[:partial]
            template_path = TEMPLATES[template_id]

Severity: Minor
Found in lib/generators/avo/eject_generator.rb - About 2 hrs 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 eject_component has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def eject_component(component_to_eject = options[:component], confirmation: true)
          # Underscore the component name
          # Example: Avo::Views::ResourceIndexComponent => avo/views/resource_index_component
          component = component_to_eject.underscore

Severity: Minor
Found in lib/generators/avo/eject_generator.rb - About 1 hr to fix

    Method eject_field_components has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def eject_field_components
              # Check if the field exists
              field_path = "lib/avo/fields/#{options["field-components"]}_field.rb"
              return say("Failed to find the `#{options["field-components"]}` field.", :yellow) if !path_exists?(field_path)
    
    
    Severity: Minor
    Found in lib/generators/avo/eject_generator.rb - About 1 hr 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

    There are no issues that match your filters.

    Category
    Status