martinisoft/funnies

View on GitHub

Showing 3 of 3 total issues

Method validate_each has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(object, attribute, value)
    if options[:format].nil? || options[:format].is_a?(Regexp)
      configuration = {
        message: "is invalid or not responding",
        format: URI::regexp(%w(http https))
Severity: Minor
Found in lib/uri_validator.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 comic_strip_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def comic_strip_url
    doc = Nokogiri::HTML::Document.parse(open(comic.comic_page))
    image_url = doc.xpath("#{comic.xpath_image}/@src").to_s

    return unless image_url.present?
Severity: Minor
Found in app/models/comic_scraper.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 flash_messages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def flash_messages
    if flash[:notice] || flash[:alert]
      type = flash[:notice] ? "success" : "alert"
      content_tag(:div, class: "alert-box #{type}", data: { alert: '' }) do
        concat(flash[:notice] || flash[:alert])
Severity: Minor
Found in app/helpers/application_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

Severity
Category
Status
Source
Language