adamphillips/activeadmin-cms

View on GitHub

Showing 4 of 6 total issues

Method to_html has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def to_html(options = {})
        html = ''

        if content_type.text_allowed?
          if content_type.markdown_allowed?
Severity: Minor
Found in lib/active_admin/cms/content.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

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

      def content_for content_key
        ret = nil
        if recipe
          if recipe.contains_content_key?(content_key)
            ret = Cms::Content.where(:page_id => id, :key => content_key)
Severity: Minor
Found in lib/active_admin/cms/page.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 meta_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def meta_data
        data = {}
        if meta_title and !meta_title.blank?
          data[:title] = meta_title
        elsif title and !title.blank?
Severity: Minor
Found in lib/active_admin/cms/page.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 input_settings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def input_settings opts = {}
          opts[:prefix]
          
          input_options = {:label => title, :input_html => {:name => "content[#{content_key}]", :id => content_key.to_s.gsub(':', '__')}}
          
Severity: Minor
Found in lib/active_admin/cms/recipe/ingredient.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