indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

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 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

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 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

      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

      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 perform has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def perform(*args)
                    invoice_id = args.shift
                    invoice = PaypalInvoice.find_by(paypal_id: invoice_id)
                
                    info = PaypalService.order_info(invoice_id)
                Severity: Minor
                Found in app/jobs/pay_pal_prepay_processing_job.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 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

                Method initialize has 35 lines of code (exceeds 25 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 1 hr to fix

                  Function display has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    Node.prototype.display = function (depth) {
                      var parent = this,
                        stepAngle,
                        angle;
                  
                  
                  Severity: Minor
                  Found in public/navigator/js-mindmap.js - About 1 hr to fix

                    Function webforms has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function webforms() {
                            /*>>input*/
                            // Run through HTML5's new input attributes to see if the UA understands any.
                            // We're using f which is the <input> element created early on
                            // Mike Taylr has created a comprehensive resource for testing these attributes
                    Severity: Minor
                    Found in app/assets/javascripts/modernizr.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language