indentlabs/notebook

View on GitHub

Showing 288 of 288 total issues

Method replace_for has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.replace_for(text, user)
    gremlins_phase = 0
    replaced_text = text.dup

    # Page tag replacements
Severity: Minor
Found in app/services/forum_replacement_service.rb - About 1 hr to fix

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

      def update
        # TODO: most things are stripped out now that we're using per-field updates, so we should
        # audit what's left of this function and what needs to stay
        content_type = content_type_from_controller(self.class)
        @content = content_type.with_deleted.find(params[:id])
    Severity: Minor
    Found in app/controllers/content_controller.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 cache_linkable_content_for_each_content_type has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def cache_linkable_content_for_each_content_type
        cache_contributable_universe_ids
        cache_current_user_content
        
        linkable_classes = @activated_content_types
    Severity: Minor
    Found in app/controllers/application_controller.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 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        axisGrid.selectAll(".levels")
           .data(d3.range(1,(cfg.levels+1)).reverse())
           .enter()
            .append("circle")
            .attr("class", "gridCircle")
    Severity: Major
    Found in app/assets/javascripts/d3-charts/radar_chart.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/d3-charts/radar_chart.js on lines 97..101

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 70.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        axisGrid.selectAll(".axisLabel")
           .data(d3.range(1,(cfg.levels+1)).reverse())
           .enter().append("text")
           .attr("class", "axisLabel")
           .attr("x", 4)
    Severity: Major
    Found in app/assets/javascripts/d3-charts/radar_chart.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/d3-charts/radar_chart.js on lines 85..90

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 70.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function render has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render () {
        return (
            <FormControl component="fieldset">
              <FormLabel component="legend">
                <i className={`material-icons ${this.props.content_color}-text left`}>
    Severity: Minor
    Found in app/javascript/components/PrivacyToggle.js - About 1 hr to fix

      Method initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(categories)
          self.categories = categories
          categories = categories.dup.to_a
      
          self.fields     = AttributeField.where(attribute_category_id: categories.map(&:id)).to_a
      Severity: Minor
      Found in app/models/serializers/categories_and_fields_serializer.rb - About 1 hr to fix

        Method initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def initialize(categories)
            self.categories = categories
            categories = categories.dup.to_a
        
            self.fields     = AttributeField.where(attribute_category_id: categories.map(&:id)).to_a
        Severity: Minor
        Found in app/models/serializers/categories_and_fields_serializer.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 set_universe_session has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_universe_session
            if params[:universe].present? && user_signed_in?
              if params[:universe] == 'all'
                session.delete(:universe_id)
              elsif params[:universe].is_a?(String) && params[:universe].to_i.to_s == params[:universe]
        Severity: Minor
        Found in app/controllers/application_controller.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 creatable_by? has a Cognitive Complexity of 13 (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)
        
            if resource.page_type == 'Universe'
        Severity: Minor
        Found in app/authorizers/content_page_authorizer.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 prosify_irc_log has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.prosify_irc_log(thredded_topic, strip_parentheticals=true)
            prose = "-!- Topic: #{thredded_topic.title}#{ENDLINE}"
            user_display_name_cache = {}
        
            thredded_topic.posts.find_each do |post|
        Severity: Minor
        Found in app/services/forums_prosify_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 add_subscription has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.add_subscription(user, plan_id)
            related_plan = BillingPlan.find_by(stripe_plan_id: plan_id, available: true)
            raise "Plan #{plan_id} not available for user #{user.id}" if related_plan.nil?
        
            # Sync with Stripe (todo pipe into StripeService)
        Severity: Minor
        Found in app/services/subscription_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

        Function render has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render () {
            return (
              <div className='card-panel'>
                <Stepper activeStep={this.state.active_step} orientation="vertical">
                  {this.steps().map((label, index) => (
        Severity: Minor
        Found in app/javascript/components/PageCollectionCreationForm.js - About 1 hr to fix

          Function list has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            list() {
              return (
                <div role="presentation">
                  <List>
                    <ListItem>
          Severity: Minor
          Found in app/javascript/components/QuickActionsSidebar.js - About 1 hr to fix

            Function loadPage has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async loadPage(page_type, page_id) {
                this.setDrawerVisible(true);
                this.setState({
                  show_data:     false,
                  category_open: {}
            Severity: Minor
            Found in app/javascript/components/PageLookupSidebar.js - About 1 hr to fix

              Method add_subscription has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.add_subscription(user, plan_id)
                  related_plan = BillingPlan.find_by(stripe_plan_id: plan_id, available: true)
                  raise "Plan #{plan_id} not available for user #{user.id}" if related_plan.nil?
              
                  # Sync with Stripe (todo pipe into StripeService)
              Severity: Minor
              Found in app/services/subscription_service.rb - About 1 hr to fix

                Method analyze_entity has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def self.analyze_entity(document_entity)
                          watson_client = new_client
                
                          entity = ::DocumentEntity.find(document_entity.to_i) # raises unless found :+1:
                          analysis = entity.document_analysis
                Severity: Minor
                Found in app/services/documents/analysis/third_party/ibm_watson_service.rb - About 1 hr to fix

                  Method relates has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def self.relates relation, with:#, where: {}
                        singularized_relation = relation.to_s.singularize
                        connecting_class      = with.to_s.singularize.camelize.constantize
                        connecting_class_name = with
                  
                  
                  Severity: Minor
                  Found in app/models/concerns/has_content_groupers.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 link_entity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def link_entity
                      # Preconditions lol
                      unless (Rails.application.config.content_types[:all].map(&:name) + [Timeline.name, Document.name]).include?(linked_entity_params[:entity_type])
                        raise "Invalid entity type #{linked_entity_params[:entity_type]}"
                      end
                  Severity: Minor
                  Found in app/controllers/documents_controller.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

                  Severity
                  Category
                  Status
                  Source
                  Language