ulmic/tramway-dev

View on GitHub

Showing 23 of 38 total issues

Function displayImages has 145 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        displayImages: function() {
            var self = this,
                ws = [],
                rowNum = 0,
                baseLine = 0,
Severity: Major
Found in tramway-landing/app/assets/javascripts/justified_images.js - About 5 hrs to fix

    Function SmoothScroll has 127 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var SmoothScroll = function (selector, options) {
    
            //
            // Variables
            //

      File smooth-scroll.js has 277 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*!
       * smooth-scroll v12.1.5: Animate scrolling to anchor links
       * (c) 2017 Chris Ferdinandi
       * MIT License
       * http://github.com/cferdinandi/smooth-scroll

        Consider simplifying this complex logical expression.
        Open

                    if (
                        // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
                        // U+007F, […]
                        (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
                        // If the character is the first character and is in the range [0-9]
        Severity: Critical
        Found in tramway-landing/app/assets/javascripts/tramway/landing/smooth-scroll.js - About 2 hrs to fix

          Function animateScroll has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  smoothScroll.animateScroll = function (anchor, toggle, options) {
          
                      // Local settings
                      var animateSettings = extend(settings || defaults, options || {}); // Merge user options with defaults
          
          

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

                var escapeCharacters = function (id) {
            
                    // Remove leading hash
                    if (id.charAt(0) === '#') {
                        id = id.substr(1);

              Consider simplifying this complex logical expression.
              Open

                          if (
                              codeUnit >= 0x0080 ||
                              codeUnit === 0x002D ||
                              codeUnit === 0x005F ||
                              codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
              Severity: Critical
              Found in tramway-landing/app/assets/javascripts/tramway/landing/smooth-scroll.js - About 1 hr to fix

                Function clickHandler has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        var clickHandler = function (event) {
                
                            // Don't run if the user prefers reduced motion
                            if (reduceMotion(settings)) return;
                
                

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

                          def record
                            if params[:key].present?
                              if Tramway::Api.other_id_methods_of(model: model_class).include? params[:key].to_sym
                                @record = model_class.find_by! params[:key] => params[:id] if params[:id].present?
                              end

                  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 error_messages has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def error_messages(object, path = []) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
                      error_messages = {}
                  
                      if object.respond_to? :errors
                        object.errors.messages.each do |name, messages|
                  Severity: Minor
                  Found in tramway-api/app/serializers/tramway/api/v1/error_serializer.rb - About 1 hr to fix

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

                          def action_is_available(project:, role: :open, model_name:, action:, current_user: nil)
                            actions = select_actions(project: project, role: role, model_name: model_name)
                            if actions.present? && !actions.is_a?(Array)
                              raise "Looks like you did not used array type to define action permissions. Remember it should be this way: `#{model_name} => [ :#{action} ]` or `#{model_name} => [ { #{action}: lambda { |record, current_user| your_condition } } ]`"
                            end
                    Severity: Minor
                    Found in tramway-api/lib/tramway/api.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( i === images.length - 1 ){
                                                    currentDiff = diff - adjustedDiff;
                                                }
                    Severity: Major
                    Found in tramway-landing/app/assets/javascripts/justified_images.js - About 45 mins to fix

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

                        def error_messages(object, path = []) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
                          error_messages = {}
                      
                          if object.respond_to? :errors
                            object.errors.messages.each do |name, messages|
                      Severity: Minor
                      Found in tramway-api/app/serializers/tramway/api/v1/error_serializer.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 block_tagline has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def block_tagline(block)
                              if block.is_a? Array
                                block.each do |_current_block|
                                  raw _current_block.page.body
                                end
                      Severity: Minor
                      Found in tramway-landing/app/helpers/tramway/landing/application_helper.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 block_title has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def block_title(block)
                              if block.is_a? Array
                                block.each do |current_block|
                                  current_block.page.title
                                end
                      Severity: Minor
                      Found in tramway-landing/app/helpers/tramway/landing/application_helper.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

                      Avoid too many return statements within this function.
                      Open

                                      return;
                      Severity: Major
                      Found in tramway-landing/app/assets/javascripts/tramway/landing/smooth-scroll.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    if (!anchor) return;
                        Severity: Major
                        Found in tramway-landing/app/assets/javascripts/tramway/landing/smooth-scroll.js - About 30 mins to fix

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

                            def show
                              @page = Tramway::Page::Page.published.find_by slug: params[:slug]
                              @blocks = @page.blocks.published.map do |block|
                                if block.block_type.header_with_form? && block.form_url.present?
                                  # FIXME: in future
                          Severity: Minor
                          Found in tramway-page/app/controllers/tramway/page/pages_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 check_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def check_action
                                    action_is_available = checking_roles.map do |role|
                                      Tramway::Api.action_is_available(
                                        action: action_name.to_sym,
                                        project: (@application_engine || application_name),
                          Severity: Minor
                          Found in tramway-api/app/controllers/tramway/api/v1/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

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

                            def active_link
                              if anchor.present?
                                "##{anchor}"
                              else
                                if external_link.present?

                          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