kpumuk/meta-tags

View on GitHub
lib/meta_tags/text_normalizer.rb

Summary

Maintainability
A
2 hrs
Test Coverage
A
98%

Method truncate_array has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def truncate_array(string_array, limit = nil, separator = "")
      return string_array if limit.nil? || limit <= 0

      length = 0
      result = []
Severity: Minor
Found in lib/meta_tags/text_normalizer.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 truncate_title has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def truncate_title(site_title, title, separator)
      global_limit = MetaTags.config.title_limit.to_i
      if global_limit > 0
        site_title_limited_length, title_limited_length = calculate_title_limits(
          site_title, title, separator, global_limit
Severity: Minor
Found in lib/meta_tags/text_normalizer.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 calculate_title_limits has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def calculate_title_limits(site_title, title, separator, global_limit)
      # What should we truncate first: site title or page title?
      main_title = MetaTags.config.truncate_site_title_first ? title : [site_title]

      main_length = main_title.map(&:length).sum + ((main_title.size - 1) * separator.length)
Severity: Minor
Found in lib/meta_tags/text_normalizer.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

There are no issues that match your filters.

Category
Status