indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

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/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/content_authorizer.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return # hurrah!
      Severity: Major
      Found in app/services/temporary_field_migration_service.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

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

          Avoid too many return statements within this method.
          Open

              return if !!content_model.columns_migrated_from_old_style?
          Severity: Major
          Found in app/services/temporary_field_migration_service.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return 'red'
            Severity: Major
            Found in app/services/emotion_service.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return 'white'
              Severity: Major
              Found in app/services/emotion_service.rb - About 30 mins to fix

                Method overview_field_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def overview_field_value(label)
                      field_cache = overview_field(label)
                      return nil if field_cache.nil?
                
                      field_cache
                Severity: Minor
                Found in app/models/concerns/has_attributes.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

                Method name_field_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def name_field_value
                      @name_field_lookup_cache ||= {}
                      cache_key = "#{self.class.name}-#{self.id.to_s}"
                
                      if @name_field_lookup_cache.key?(cache_key)
                Severity: Minor
                Found in app/models/concerns/has_attributes.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

                Method queue_analysis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def queue_analysis
                    return redirect_back(fallback_location: documents_path, notice: "That document doesn't exist!") unless @document.present?
                    return redirect_back(fallback_location: documents_path, notice: "Document analysis is a feature for Premium users.") unless @document.user.on_premium_plan?
                    return redirect_back(fallback_location: documents_path, notice: "You don't have permission to do that!") unless @document.user == current_user
                    
                Severity: Minor
                Found in app/controllers/documents_controller.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

                Method get_field_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_field_value(category, field, fallback=nil)
                      category = AttributeCategory.find_by(
                        label:       category,
                        entity_type: self.class.name.downcase,
                        user_id:     self.user_id,
                Severity: Minor
                Found in app/models/concerns/has_attributes.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

                Method toggle_archive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def toggle_archive
                    # todo Since this method is triggered via a GET in floating_action_buttons, a malicious user could technically archive
                    # another user's content if they're able to send that user to a specifically-crafted URL or inject that URL somewhere on
                    # a page (e.g. img src="/characters/1234/toggle_archive"). Since archiving is reversible this seems fine for release, but
                    # is something that should be fixed asap before any abuse happens.
                Severity: Minor
                Found in app/controllers/content_controller.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

                Method successful_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def successful_response(url, notice)
                    respond_to do |format|
                      format.html {
                        if params.key?(:override) && params[:override].key?(:redirect_path)
                          redirect_to params[:override][:redirect_path], notice: notice
                Severity: Minor
                Found in app/controllers/content_controller.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

                Method cache_current_user_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def cache_current_user_content
                    return if @current_user_content
                
                    @current_user_content = {}
                    return unless user_signed_in?
                Severity: Minor
                Found in app/controllers/application_controller.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

                Function exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function(api) {
                  var validEnv = ['development', 'test', 'production']
                  var currentEnv = api.env()
                  var isDevelopmentEnv = api.env('development')
                  var isProductionEnv = api.env('production')
                Severity: Minor
                Found in babel.config.js - 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

                Method creatable_by? has a Cognitive Complexity of 6 (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.user_has_fewer_owned_universes_than_plan_limit?(user: user)
                Severity: Minor
                Found in app/authorizers/universe_core_content_authorizer.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

                Method readable_by? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def readable_by?(user)
                    return true if PermissionService.content_is_public?(content: resource)
                    return true if PermissionService.user_owns_content?(user: user, content: resource)
                
                    if resource.page_type == 'Universe'
                Severity: Minor
                Found in app/authorizers/content_page_authorizer.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

                Method index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def index
                    @content_type_class = content_type_from_controller(self.class)
                    pluralized_content_name = @content_type_class.name.downcase.pluralize
                
                    @page_title = "My #{pluralized_content_name}"
                Severity: Minor
                Found in app/controllers/content_controller.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

                Method stats has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def stats
                    @commissions = BasilCommission.all.with_deleted
                
                    @queued = BasilCommission.where(completed_at: nil)
                    @completed = BasilCommission.where.not(completed_at: nil).with_deleted
                Severity: Minor
                Found in app/controllers/basil_controller.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

                Method information_change has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def information_change
                    valid_token = params[:stripeToken]
                    if valid_token.nil?
                      flash[:alert] = "We couldn't validate the card information you entered. Please make sure you have Javascript enabled in your browser."
                      return redirect_back fallback_location: payment_info_path
                Severity: Minor
                Found in app/controllers/subscriptions_controller.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