claudetech/cdn-tags-rails

View on GitHub

Showing 2 of 2 total issues

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

  def self.map_sources(sources, config_key)
    config = CdnTags.configuration
    do_replace = config.cdn_environments.include? config.environment.to_sym
    return sources unless do_replace || config.should_raise
    sources.map do |s|
Severity: Minor
Found in lib/cdn_tags/helpers.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 update_rails_precompile! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_rails_precompile!
      return unless self.add_to_precompile
      scripts_precompile = self.scripts_urls.keys.map { |s| should_append_extension(s) ? "#{s}.js" : s }
      stylesheets_precompile = self.stylesheets_urls.keys.map { |s| should_append_extension(s) ? "#{s}.css" : s }
      added_precompile = scripts_precompile + stylesheets_precompile
Severity: Minor
Found in lib/cdn_tags/configuration.rb - About 45 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