ministryofjustice/atet

View on GitHub

Showing 13 of 23 total issues

Function exports has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
Severity: Major
Found in babel.config.js - About 3 hrs to fix

Function SessionPrompt has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SessionPrompt = (function () {
 
let settings = {
SECOND: 1000
};
Severity: Major
Found in app/javascript/packs/components/SessionPrompt.js - About 2 hrs to fix

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

class FormCollectionProxy
include Enumerable
 
def initialize(child_form_class_name, collection_name, parent_form_instance)
@parent_form_instance = parent_form_instance
Severity: Minor
Found in app/forms/form_collection_proxy.rb - About 2 hrs to fix

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

def self.but_skip_postcode_validation
Module.new do
extend ActiveSupport::Concern
 
const_set :ADDRESS_LINE_LENGTH, 50
Severity: Minor
Found in app/forms/address_attributes.rb - About 1 hr to fix

Function SessionPrompt has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const SessionPrompt = (function () {
 
let settings = {
SECOND: 1000
};
Severity: Minor
Found in app/javascript/packs/components/SessionPrompt.js - About 1 hr to fix

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

def illegal_date?(record, attribute, value)
# The date type in rails seems a bit basic in terms of validation - it will accept 31/2/xxxx but not 32/2/xxxx,
# neither of which should be valid so we are going to validate better here.
raw_value = read_attribute_before_type_cast(record, attribute, default: nil)
if raw_value.is_a?(String) && raw_value.blank?
Severity: Minor
Found in app/validators/date_validator.rb - About 55 mins to fix

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

def date_is_past?
return if end_date.blank? || start_date.blank?
return unless end_date.is_a?(Date) && start_date.is_a?(Date)
 
errors.add(:start_date, :date_in_future) if Time.zone.today < start_date
Severity: Minor
Found in app/forms/employment_form.rb - About 45 mins to fix

Method start_date_before_notice_period_end_date? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def start_date_before_notice_period_end_date?
return if notice_period_end_date.blank? || start_date.blank?
return unless notice_period_end_date.is_a?(Date) && start_date.is_a?(Date)
 
return unless notice_period_end_date < start_date
Severity: Minor
Found in app/forms/employment_form.rb - About 35 mins to fix

Method end_date_before_start_date? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def end_date_before_start_date?
return if end_date.blank? || start_date.blank?
return unless end_date.is_a?(Date) && start_date.is_a?(Date)
 
return unless end_date < start_date
Severity: Minor
Found in app/forms/employment_form.rb - About 35 mins to fix

Method new_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def new_date(year, mon, mday = nil)
mday ||= 1 if omit_day
year = (1900 + year.to_i).to_s if allow_2_digit_year && year.present? && year.strip.length <= 2
Date.strptime("#{year}-#{mon}-#{mday}", '%Y-%m-%d')
rescue ::Date::Error, TypeError
Severity: Minor
Found in app/types/et_date_type.rb - About 35 mins to fix

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

def value_from_multiparameter_assignment(value)
if value.is_a?(Hash)
value = value.stringify_keys if value.respond_to?(:stringify_keys)
begin
super(1 => value['year'], 2 => value['month'], 3 => value['day'])
Severity: Minor
Found in app/types/gds_date_type.rb - About 25 mins to fix

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

def illegal_year?(value)
# Needs to verify that four digits are given for a year
return false if value.nil?
 
case value
Severity: Minor
Found in app/validators/date_validator.rb - About 25 mins to fix

Function monitorDownloadLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function monitorDownloadLink() {
const successNode = document.querySelector('.pdf-success');
const failureNode = document.querySelector('.pdf-failure');
const url = successNode.getAttribute('href')
let http = new XMLHttpRequest();
Severity: Minor
Found in app/javascript/packs/pages/claims/ClaimConfirmationPage.js - About 25 mins to fix
Severity
Category
Status
Source
Language