indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

Method timeline has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def timeline
        timeline = Timeline.find_by(id: params[:id].to_i)
        events   = timeline.timeline_events

        render json: {
Severity: Minor
Found in app/controllers/api/v1/api_controller.rb - About 1 hr to fix

    Method link_field_update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def link_field_update
        @attribute_field = AttributeField.find_by(id: params[:field_id].to_i)
        attribute_value = @attribute_field.attribute_values.order('created_at desc').find_or_initialize_by(entity_params)
        attribute_value.user_id ||= current_user.id
    
    
    Severity: Minor
    Found in app/controllers/content_controller.rb - About 1 hr to fix

      Method update has 28 lines of code (exceeds 25 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

        Method show has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def show
            @page_title = @folder.title || 'Untitled folder'
        
            @parent_folder = @folder.parent_folder
            @child_folders = Folder.where(parent_folder: @folder)
        Severity: Minor
        Found in app/controllers/folders_controller.rb - About 1 hr to fix

          Method create_prepay_invoice has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.create_prepay_invoice(n_months)
              # Create a Paypal invoice to redirect to for payment
              request = PayPalCheckoutSdk::Orders::OrdersCreateRequest::new
              request.request_body({
                intent: "CAPTURE",
          Severity: Minor
          Found in app/services/paypal_service.rb - About 1 hr to fix

            Method content_to_outline has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def content_to_outline
                content_types = current_user.content.except('Document').except('Timeline').keys
            
                text = ""
                content_types.each do |content_type|
            Severity: Minor
            Found in app/controllers/export_controller.rb - About 1 hr to fix

              Function _selectOption has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _selectOption(optionEl) {
                    let key = optionEl.id;
                    if (!$(optionEl).hasClass('disabled') && !$(optionEl).hasClass('optgroup') && key.length) {
                      let selected = true;
              
              
              Severity: Minor
              Found in app/assets/javascripts/z_select.js - About 1 hr to fix

                Method perform has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def perform(*args)
                    report_date = Date.current - 1.day
                    timespan    = report_date.beginning_of_day..report_date.end_of_day
                
                    report = EndOfDayAnalyticsReport.find_or_initialize_by(day: report_date)
                Severity: Minor
                Found in app/jobs/end_of_day_analytics_job.rb - About 1 hr to fix

                  Method create_default_attribute_categories has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def self.create_default_attribute_categories(user)
                        # Don't create any attribute categories for AttributeCategories or AttributeFields that share the ContentController
                        return [] if ['attribute_category', 'attribute_field'].include?(content_name)
                  
                        YAML.load_file(Rails.root.join('config', 'attributes', "#{content_name}.yml")).map do |category_name, defaults|
                  Severity: Minor
                  Found in app/models/concerns/has_attributes.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 perform has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def perform(*args)
                      report_date = args.shift.to_date
                      timespan    = report_date.beginning_of_day..report_date.end_of_day
                  
                      report = EndOfDayAnalyticsReport.find_or_initialize_by(day: report_date)
                  Severity: Minor
                  Found in app/jobs/backfilled_end_of_day_analytics_job.rb - About 1 hr to fix

                    Method perform has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def perform(*args)
                        analysis_id = args.shift
                    
                        analysis = DocumentAnalysis.find(analysis_id)
                        return unless analysis.present?
                    Severity: Minor
                    Found in app/jobs/document_analysis_job.rb - About 1 hr to fix

                      Method redeem_code has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def redeem_code
                          code = PageUnlockPromoCode.find_by(code: params.require(:promotional_code).permit(:promo_code)[:promo_code])
                      
                          if code.nil?
                            redirect_back(fallback_location: subscription_path, alert: "This isn't a valid promo code.")
                      Severity: Minor
                      Found in app/controllers/subscriptions_controller.rb - About 1 hr to fix

                        Method question_for has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.question_for(content)
                            return unless content.present?
                        
                            categories_for_this_type = AttributeCategory.where(
                              user:        content.user,
                        Severity: Minor
                        Found in app/services/serendipitous_service.rb - About 1 hr to fix

                          Function bind has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                Function.prototype.bind = function bind(that) {
                          
                                  var target = this;
                          
                                  if (typeof target != "function") {
                          Severity: Minor
                          Found in app/assets/javascripts/modernizr.js - About 1 hr to fix

                            Function isEventSupported has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                isEventSupported = (function() {
                            
                                  var TAGNAMES = {
                                    'select': 'input', 'change': 'input',
                                    'submit': 'form', 'reset': 'form',
                            Severity: Minor
                            Found in app/assets/javascripts/modernizr.js - About 1 hr to fix

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

                                Method analyze has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def self.analyze(analysis_id)
                                        analysis = DocumentAnalysis.find(analysis_id)
                                        document = analysis.document
                                
                                        # Length counters
                                Severity: Minor
                                Found in app/services/documents/analysis/counting_service.rb - About 1 hr to fix

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

                                    def show    
                                      content_type = content_type_from_controller(self.class)
                                      return redirect_to(root_path, notice: "That page doesn't exist!") unless valid_content_types.include?(content_type.name)
                                  
                                      @content = content_type.find_by(id: params[:id])
                                  Severity: Minor
                                  Found in app/controllers/content_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 universe_field_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def universe_field_value
                                        universe_field_cache = universe_field
                                        return nil unless self.respond_to?(:universe_id)
                                        return self.universe_id if universe_field_cache.nil?
                                  
                                  
                                  Severity: Minor
                                  Found in app/models/concerns/has_attributes.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

                                  Function keyboardControlManager has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function keyboardControlManager ( keyboardControls ) {
                                      /**
                                       * Listens to the keyboard events and pushes items into the stack
                                       *
                                       * @param {KeyboardEvent} event
                                  Severity: Minor
                                  Found in app/assets/javascripts/keyboardControls.js - 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language