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
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
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
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;
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) {
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",
Class StyleguideController
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class StyleguideController < ApplicationController
layout 'styleguide/documentation'
def layouts
render layout: 'styleguide/documentation'
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),
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) {
Function _positionComponent
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
StickyColumn.prototype._positionComponent = function() {
var scrollTop;
if (!this.isInSidebar) {
return;
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()) {
Function iframeResizer
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.iframeResizer = function(msgPrefix, targetOrigin, minFrameHeight) {
'use strict';
var timer, frameDefaultOverflow;
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,
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;
Function start
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
start: function() {
if (!window.postMessage) {
return;
}
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)
- Read upRead up
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
- Read upRead up
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']
- Read upRead up
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?)
- Read upRead up
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;