moneyadviceservice/frontend

View on GitHub

Showing 24 of 43 total issues

File legacy_maps_redirects.rb has 1188 lines of code (exceeds 250 allowed). Consider refactoring.
Open

LEGACY_MAPS_HOST = %r{^(www.)?moneyandpensionsservice.org.uk$}.freeze

r301 %r{^/?}, 'https://adviser.moneyhelper.org.uk/en/faqs-independent-confidential-impartial-money-advice', host: 'moneyadviser.moneyhelper.org.uk'

r301 %r{^/?$}, 'https://www.maps.org.uk/en', host: LEGACY_MAPS_HOST
Severity: Major
Found in lib/legacy_maps_redirects.rb - About 3 days to fix

    Class ApplicationController has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ApplicationController < ActionController::Base
      rescue_from Mas::Cms::HttpRedirect, with: :redirect_page
      rescue_from Mas::Cms::Errors::ResourceNotFound, with: :not_found
    
      protect_from_forgery with: :exception
    Severity: Minor
    Found in app/controllers/application_controller.rb - About 4 hrs to fix

      Function CookieController has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var CookieController = function (opts) {
        this.config = Object.assign(defaults, opts);
      
        // TODO: replace locale and textStrings with the existing i18n module
        // This appears to be not functioning as it should right now
      Severity: Major
      Found in app/assets/javascripts/modules/mas_cookieController.js - About 3 hrs to fix

        File GlobalNav.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        define(['jquery', 'DoughBaseComponent', 'mediaQueries', 'utilities', 'common'], function($, DoughBaseComponent, mediaQueries, utilities, common) {
          'use strict';
        
          var GlobalNav;
        
        
        Severity: Minor
        Found in app/assets/javascripts/components/GlobalNav.js - About 3 hrs to fix

          Function _setUpKeyboardEvents has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            GlobalNav.prototype._setUpKeyboardEvents = function() {
              var self = this;
          
              this.$globalNav.keydown(function(e) {
                if (e.which === 32 || e.which === 40) {
          Severity: Major
          Found in app/assets/javascripts/components/GlobalNav.js - About 2 hrs to fix

            File mas_collapsable.js has 271 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            define(["jquery", "common"], function ($, MAS) {
              "use strict";
            
              var defaults = {
                name: "not set",
            Severity: Minor
            Found in app/assets/javascripts/modules/mas_collapsable.js - About 2 hrs to fix

              Class StyleguideController has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class StyleguideController < ApplicationController
                layout 'styleguide/documentation'
              
                def layouts
                  render layout: 'styleguide/documentation'
              Severity: Minor
              Found in app/controllers/styleguide_controller.rb - About 2 hrs to fix

                Function _setupEach has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  Collapsible.prototype._setupEach = function (i, el) {
                    var $el = $(el),
                      _this = this,
                      _target = _getTarget($el, _this.o),
                      _items = _getItems(_target, _this.o),
                Severity: Major
                Found in app/assets/javascripts/modules/mas_collapsable.js - About 2 hrs to fix

                  Function _modifyButtonHTML has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    Collapsible.prototype._modifyButtonHTML = function (i) {
                      var icon, txt;
                      var trigger = this.sections[i].trigger;
                  
                      if (this.o.showText) {
                  Severity: Minor
                  Found in app/assets/javascripts/modules/mas_collapsable.js - About 1 hr to fix

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

                      StickyColumn.prototype._positionComponent = function() {
                        var scrollTop;
                    
                        if (!this.isInSidebar) {
                          return;
                    Severity: Minor
                    Found in app/assets/javascripts/components/StickyColumn.js - About 1 hr to fix

                      Function _setUpDesktopInteraction has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        GlobalNav.prototype._setUpDesktopInteraction = function() {
                          var self = this;
                      
                          // touch event outside of global nav triggers close subnav
                          if (!mediaQueries.atSmallViewport()) {
                      Severity: Minor
                      Found in app/assets/javascripts/components/GlobalNav.js - About 1 hr to fix

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

                        window.iframeResizer = function(msgPrefix, targetOrigin, minFrameHeight) {
                          'use strict';
                        
                          var timer, frameDefaultOverflow;
                        
                        
                        Severity: Minor
                        Found in app/assets/javascripts/syndication/iframeResizer.js - About 1 hr to fix

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

                          CookieController.prototype.addOptionalCookies = function () {
                            var textStrings = this.textStrings[this.locale];
                            var analytics = {
                              name: "analytics",
                              recommendedState: true,
                          Severity: Minor
                          Found in app/assets/javascripts/modules/mas_cookieController.js - About 1 hr to fix

                            Function Collapsible has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              var Collapsible = function (opts) {
                                this.o = $.extend({}, defaults, opts);
                                this.sections = [];
                                this.selected = false;
                            
                            
                            Severity: Minor
                            Found in app/assets/javascripts/modules/mas_collapsable.js - About 1 hr to fix

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

                                  start: function() {
                                    if (!window.postMessage) {
                                      return;
                                    }
                              
                              
                              Severity: Minor
                              Found in app/assets/javascripts/syndication/iframeResizer.js - About 1 hr to fix

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

                                  def to_ostruct
                                    OpenStruct.new(self).tap do |ostruct|
                                      ostruct.each_pair do |attribute, value|
                                        if value.is_a?(Hash)
                                          ostruct.send("#{attribute}=", value.to_ostruct)
                                Severity: Minor
                                Found in lib/core_ext.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 validate_each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def validate_each(record, attribute, value)
                                      if value.nil?
                                        original = record.attributes_before_type_cast[attribute.to_s]
                                        record.errors.add(attribute, 'invalid date') if original.present?
                                        return
                                Severity: Minor
                                Found in lib/validators/date_of_birth.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def call(env)
                                    status, headers, body = @app.call(env)
                                
                                    if (headers['Set-Cookie'].present? || env['HTTP_SET_COOKIE'].present?) && Rack::Request.new(env).ssl?
                                      cookie = headers['Set-Cookie'] || env['HTTP_SET_COOKIE']
                                Severity: Minor
                                Found in app/middleware/partner_tools_cookies.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 build has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def self.build(item, limit = 6)
                                    category_contents = sibling_and_cousin_contents(item)
                                    related_content = []
                                
                                    until category_contents.all?(&:empty?)
                                Severity: Minor
                                Found in app/domain/related_content.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 app/assets/javascripts/components/StickyColumn.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language