indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

Method add_account has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def add_account
    # Tie any universe contributor invites with this email to this user
    if resource.persisted?
      potential_contributor_records = Contributor.where(email: resource.email.downcase, user_id: nil)
      
Severity: Minor
Found in app/controllers/registrations_controller.rb - About 55 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 8 (exceeds 5 allowed). Consider refactoring.
Open

  def readable_by?(user)
    return true if user && resource.user_id == user.id
    return true if user && user.site_administrator?
    return true if resource.privacy == 'public'
    return true if resource.universe.present? && resource.universe.privacy == 'public'
Severity: Minor
Found in app/authorizers/document_authorizer.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

Avoid deeply nested control flow statements.
Open

                if (activeParent.children[i] === mindmap.activeNode) {
                  newNode = activeParent.children[i + 1];
                }
Severity: Major
Found in public/navigator/js-mindmap.js - About 45 mins to fix

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

      def set_universe_scope
        if user_signed_in? && session.key?(:universe_id)
          @universe_scope = Universe.find_by(id: session[:universe_id])
    
          if @universe_scope && @universe_scope.user_id != current_user.try(:id)
    Severity: Minor
    Found in app/controllers/application_controller.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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform(*args)
        share_comment_id = args.shift
        comment = ShareComment.find_by(id: share_comment_id)
        return unless comment.present?
    
    
    Severity: Minor
    Found in app/jobs/content_page_share_notification_job.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 review_year has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def review_year
        @year = params[:year].to_i
        comparable_year = "Jan 1, #{@year}".to_date
    
        @created_content = {}
    Severity: Minor
    Found in app/controllers/data_controller.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 content_with_multiple_queries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def content_with_multiple_queries(
          content_types: Rails.application.config.content_type_names[:all],
          page_scoping:  { user_id: self.id },
          universe_id:   nil
        )
    Severity: Minor
    Found in app/models/concerns/has_content.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 description_for_character has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def description_for_character
        occupation  = @character.get_field_value('Social', 'Occupation')
        background  = @character.get_field_value('History', 'Background')
        motivations = @character.get_field_value('Nature', 'Motivations')
        mannerisms  = @character.get_field_value('Nature', 'Mannerisms')
    Severity: Minor
    Found in app/controllers/conversation_controller.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

    Avoid deeply nested control flow statements.
    Open

                    if (activeParent.children[i] === mindmap.activeNode) {
                      newNode = activeParent.children[i - 1];
                    }
    Severity: Major
    Found in public/navigator/js-mindmap.js - About 45 mins to fix

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

        def update
          if user_signed_in? && current_user == @page_collection.user    
            @page_collection.page_types = page_collection_page_types_param if params.require(:page_collection).key?(:page_types)
            if @page_collection.update(page_collection_params)
              redirect_to @page_collection, notice: 'Collection settings updated successfully.'
      Severity: Minor
      Found in app/controllers/page_collections_controller.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 prosify_html has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.prosify_html(thredded_topic, strip_parentheticals=true)
          prose = ""
          user_display_name_cache = {}
      
          thredded_topic.posts.find_each do |post|
      Severity: Minor
      Found in app/services/forums_prosify_service.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 replace_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.replace_for(text, user)
          gremlins_phase = 1
          replaced_text = text.dup
      
          # Page tag replacements
      Severity: Minor
      Found in app/services/forum_replacement_service.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(content, include_blank_fields: false)
          self.categories       = content.class.attribute_categories(content.user).where(hidden: [false, nil]).eager_load(attribute_fields: :attribute_values)
          self.fields           = AttributeField.where(attribute_category_id: self.categories.map(&:id), hidden: [false, nil])
          self.attribute_values = Attribute.where(attribute_field_id: self.fields.map(&:id), entity_type: content.page_type, entity_id: content.id).order('created_at desc')
          self.universe         = (content.class.name == Universe.name) ? nil : content.universe
      Severity: Minor
      Found in app/models/serializers/api_content_serializer.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 resource.privacy == 'public'
          return true if user && resource.user_id == user.id
          return true if resource.universe.present? && resource.universe.privacy == 'public'
          return true if user && resource.universe.present? && resource.universe.user_id == user.id
      Severity: Minor
      Found in app/authorizers/timeline_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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          user = User.find_by(id: user_following_params.fetch(:followed_user_id))
          return unless user.present?
          return if user_signed_in? && current_user.blocked_by?(user)
      
      
      Severity: Minor
      Found in app/controllers/user_followings_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

      Function RadarChart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function RadarChart(id, data, options) {
          var cfg = {
           w: 600,                //Width of the circle
           h: 600,                //Height of the circle
           margin: {top: 100, right: 100, bottom: 100, left: 100}, //The margins of the SVG
      Severity: Minor
      Found in app/assets/javascripts/d3-charts/radar_chart.js - 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 changelog has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def changelog
          content_type = content_type_from_controller(self.class)
          return redirect_to root_path unless valid_content_types.include?(content_type.name)
          @content = content_type.find_by(id: params[:id])
          return redirect_to(root_path, notice: "You don't have permission to view that content.") if @content.nil?
      Severity: Minor
      Found in app/controllers/content_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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          notification = Notification.find_by(id: params[:id])
          return redirect_to root_path unless notification.present?
          return redirect_to root_path unless user_signed_in? && notification.user == current_user
      
      
      Severity: Minor
      Found in app/controllers/notifications_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 update_custom_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_custom_attributes
            (self.custom_attribute_values || []).each do |attribute|
              field = AttributeField.includes(:attribute_category).find_by(  # THIS GETS CALLED A TON
                name: attribute[:name],
                user: self.user,
      Severity: Minor
      Found in app/models/concerns/has_attributes.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 unlink_entity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def unlink_entity
          document = Document.find_by(id: params[:id])
          return unless document.present?
      
          entity   = document.document_entities.find_by(
      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

      Severity
      Category
      Status
      Source
      Language