yegor256/jekyll-bits

View on GitHub

Showing 4 of 4 total issues

Method jb_uri has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def jb_uri(page)
      uri = ''
      uri = page['image'] if page['image']
      yaml = page['jb_picture']
      if yaml
Severity: Minor
Found in lib/jekyll-bits/picture.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

Method jb_picture_head has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def jb_picture_head(page)
      uri = jb_abs(jb_uri(page))
      return '' if uri.empty?
      html = "<meta name='og:image' content='#{CGI.escapeElement(uri)}'/>"
      html += "<meta name='twitter:image' content='#{CGI.escapeElement(uri)}'/>"
Severity: Minor
Found in lib/jekyll-bits/picture.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

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

    def jb_picture_body(page)
      uri = jb_uri(page)
      return '' if uri.empty?
      yaml = page['jb_picture']
      html = "<img itemprop='image' alt='#{CGI.escapeHTML(jb_alt(page))}'"
Severity: Minor
Found in lib/jekyll-bits/picture.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 jb_alt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def jb_alt(page)
      alt = ''
      yaml = page['jb_picture']
      if yaml && yaml.is_a?(Hash)
        if yaml['alt']
Severity: Minor
Found in lib/jekyll-bits/picture.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