indentlabs/notebook

View on GitHub
app/services/content_formatter_service.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method replacement_for_token has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def self.replacement_for_token(token, viewing_user, plaintext=false)
    return unknown_link_template(token) unless token.key?(:content_type) && token.key?(:content_id)
    begin
      content_class = token[:content_type].titleize.constantize
    rescue
Severity: Minor
Found in app/services/content_formatter_service.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 chip_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.chip_template(class_model=nil)
    content_tag(:span, class: 'chip') do
      body = ''
      if class_model
        body += content_tag(:span, class: class_model ? "#{class_model.text_color}" : '') do
Severity: Minor
Found in app/services/content_formatter_service.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 link_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.link_for(content_model)
    [
      Rails.env.production? ? 'https://' : 'http://',
      Rails.env.production? ? 'www.notebook.ai' : 'localhost:3000', # Rails.application.routes.default_url_options[:host]?
      content_model.class.name != Document.name ? '/plan/' : '/',
Severity: Minor
Found in app/services/content_formatter_service.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