ministryofjustice/atet

View on GitHub

Showing 23 of 23 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function enableOtherFieldsWhenAllowed() {
privateFields.etIssueFeeEl().on('change keyup keypress', updateOtherFields);
privateFields.etHearingFeeEl().on('change keyup keypress', updateOtherFields);
privateFields.etReconsiderationFeeEl().on('change keyup keypress', updateOtherFields);
privateFields.eatIssueFeeEl().on('change keyup keypress', updateOtherFields);
Severity: Major
Found in app/javascript/packs/pages/refunds/FeesPage.js and 1 other location - About 3 hrs to fix
app/javascript/packs/pages/refunds/FeesPage.js on lines 27..33

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function updateTotalFeesOnChange() {
privateFields.etIssueFeeEl().on('change keyup keypress', updateTotalFees);
privateFields.etHearingFeeEl().on('change keyup keypress', updateTotalFees);
privateFields.etReconsiderationFeeEl().on('change keyup keypress', updateTotalFees);
privateFields.eatIssueFeeEl().on('change keyup keypress', updateTotalFees);
Severity: Major
Found in app/javascript/packs/pages/refunds/FeesPage.js and 1 other location - About 3 hrs to fix
app/javascript/packs/pages/refunds/FeesPage.js on lines 19..25

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

function setupReveal() {
document.querySelectorAll('*[data-reveal-on-selector]').forEach(function (node) {
const selector = node.attributes['data-reveal-on-selector'].value;
const value = JSON.parse(node.attributes['data-reveal-on-value'].value);
Components.RevealOnRadioButton(node, selector, value);
Severity: Major
Found in app/javascript/packs/pages/claims/ClaimTypePage.js and 1 other location - About 2 hrs to fix
app/javascript/packs/pages/claims/EmploymentPage.js on lines 3..9

Identical blocks of code found in 2 locations. Consider refactoring.
Open

function setupReveal() {
document.querySelectorAll('*[data-reveal-on-selector]').forEach(function (node) {
const selector = node.attributes['data-reveal-on-selector'].value;
const value = JSON.parse(node.attributes['data-reveal-on-value'].value);
Components.RevealOnRadioButton(node, selector, value);
Severity: Major
Found in app/javascript/packs/pages/claims/EmploymentPage.js and 1 other location - About 2 hrs to fix
app/javascript/packs/pages/claims/ClaimTypePage.js on lines 3..9

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

unMonitorChanges() {
this.allowPhoneOrVideoAttendanceCheckboxes().forEach((checkbox) => {
checkbox.removeEventListener('change', this.phoneOrVideoCheckboxChange.bind(this))
})
}
app/javascript/packs/controllers/claim_form_claimant_controller.js on lines 37..41

Similar blocks of code found in 2 locations. Consider refactoring.
Open

monitorChanges() {
this.allowPhoneOrVideoAttendanceCheckboxes().forEach((checkbox) => {
checkbox.addEventListener('change', this.phoneOrVideoCheckboxChange.bind(this))
})
}
app/javascript/packs/controllers/claim_form_claimant_controller.js on lines 43..47

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def update
resource.assign_attributes params[current_step].permit!
 
if params[:commit] == "claims.#{current_step}.add_fields"
resource.secondary_respondents.build
Severity: Minor
Found in app/controllers/multiple_respondents_controller.rb and 1 other location - About 30 mins to fix
app/controllers/multiple_claimants_controller.rb on lines 6..17

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def update
resource.assign_attributes params[current_step].permit!
 
if params[:commit] == "claims.#{current_step}.add_fields"
resource.secondary_claimants.build
Severity: Minor
Found in app/controllers/multiple_claimants_controller.rb and 1 other location - About 30 mins to fix
app/controllers/multiple_respondents_controller.rb on lines 6..17

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
Severity
Category
Status
Source
Language