indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

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

    def random_image_including_private(format: :medium)
      @random_image_including_private_cache ||= {}
      key = self.class.name + self.id.to_s
      return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key)

Severity: Minor
Found in app/models/concerns/has_image_uploads.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 creatable_by? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.creatable_by?(user)
    return false unless user.present?
    return false if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(user.email)

    return true if PermissionService.billing_plan_allows_extended_content?(user: user)
Severity: Minor
Found in app/authorizers/extended_content_authorizer.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 readable_by? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def readable_by? user
    return true if user && user.site_administrator?
    return true if ::PermissionService.user_owns_any_containing_universe?(user: user, content: resource)
    return true if ::PermissionService.user_owns_content?(user: user, content: resource)
    return true if ::PermissionService.content_is_public?(content: resource)
Severity: Minor
Found in app/authorizers/content_authorizer.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    document = Document.with_deleted.find_or_initialize_by(id: params[:id])

    unless document.updatable_by?(current_user)
      redirect_to(dashboard_path, notice: "You don't have permission to do that!")
Severity: Minor
Found in app/controllers/documents_controller.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 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

Avoid too many return statements within this method.
Open

    return true if ::PermissionService.user_can_contribute_to_containing_universe?(user: user, content: resource)
Severity: Major
Found in app/authorizers/content_authorizer.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return false
    Severity: Major
    Found in app/authorizers/document_authorizer.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return false
      Severity: Major
      Found in app/authorizers/universe_core_content_authorizer.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return false
        Severity: Major
        Found in app/authorizers/content_page_authorizer.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return redirect_to root_path, notice: "You don't have permission to view that content."
          Severity: Major
          Found in app/controllers/content_controller.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return false
            Severity: Major
            Found in app/authorizers/content_page_authorizer.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return true if user.active_promo_codes.any?
              Severity: Major
              Found in app/authorizers/extended_content_authorizer.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return true if PermissionService.content_is_in_a_public_universe?(content: resource)
                Severity: Major
                Found in app/authorizers/attribute_authorizer.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                      return false
                  Severity: Major
                  Found in app/authorizers/timeline_authorizer.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                        return true if ::PermissionService.content_is_in_a_public_universe?(content: resource)
                    Severity: Major
                    Found in app/authorizers/content_authorizer.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return true if is_premium_page && PermissionService.user_is_on_premium_plan?(user: user)
                      Severity: Major
                      Found in app/authorizers/content_page_authorizer.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                            return true if user && resource.universe.present? && resource.universe.contributors.pluck(:user_id).include?(user.id)
                        Severity: Major
                        Found in app/authorizers/timeline_authorizer.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                              return true if user && user.site_administrator?
                          Severity: Major
                          Found in app/authorizers/timeline_authorizer.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                return true if user && resource.universe.present? && resource.universe.user_id == user.id
                            Severity: Major
                            Found in app/authorizers/document_authorizer.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                  return false
                              Severity: Major
                              Found in app/authorizers/attribute_authorizer.rb - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language