app/assets/javascripts/fae/form/_validator.js
File _validator.js
has 392 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/* global Fae, judge, FCH */
/**
* Fae form validator
* @namespace form.validator
Function formValidate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
formValidate: function ($scope) {
var _this = this;
if (typeof $scope === 'undefined') {
$scope = FCH.$document;
Function _buildErrorLinks
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_buildErrorLinks: function ($scope) {
const $header = $('.js-content-header');
const headerHeight = $header[0].getBoundingClientRect().height;
if (typeof $scope === 'undefined') {
Function _removeIgnoredErrors
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
_removeIgnoredErrors: function (messages) {
// Ignored error messages from Judge:
// 'Judge validation for Release#name not allowed'
// 'Slug Request error: 0'
var ignored_error_substrings = ['Judge validation', 'Request error'];
- 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
Function stripValidation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
stripValidation: function ($field, kind) {
var validations = $field.data('validate');
for (var i = 0; i < validations.length; i++) {
// validation items can be strings or JSON objects
- 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"