Showing 21 of 21 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
var validFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
var messageToShow = validMessage || $validationProvider.getDefaultMsg(validation).success;
var validCallback = $parse(attrs.validCallback);
var messageId = attrs.messageId;
var validationGroup = attrs.validationGroup;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 330.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
var invalidFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
var messageToShow = validMessage || $validationProvider.getDefaultMsg(validation).error;
var invalidCallback = $parse(attrs.invalidCallback);
var messageId = attrs.messageId;
var validationGroup = attrs.validationGroup;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 330.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function Validator
has 278 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Validator($injector) {
var $validationProvider = $injector.get('$validation');
var $q = $injector.get('$q');
var $timeout = $injector.get('$timeout');
var $compile = $injector.get('$compile');
Function Provider
has 156 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Provider() {
var $injector;
var $scope;
var $http;
var $q;
Function link
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, element, attrs, ctrl) {
/**
* All attributes
*/
var useViewValue = attrs.useViewValue !== 'false';
Function exports
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(grunt) {
require('time-grunt')(grunt);
// Grunt Config
grunt.initConfig({
File validator.directive.js
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function() {
angular
.module('validation.directive')
.directive('validator', Validator);
Function checkValidation
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
var checkValidation = function(scope, element, attrs, ctrl, validation, value) {
var validators = validation.slice(0);
var validatorExpr = validators[0].trim();
var paramIndex = validatorExpr.indexOf('=');
var validator = paramIndex === -1 ? validatorExpr : validatorExpr.substr(0, paramIndex);
Function validate
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.validate = function(form) {
var deferred = $q.defer();
var idx = 0;
if (form === undefined) {
Function invalidFunc
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
var invalidFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
Function validFunc
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
var validFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.setErrorHTML = function(func) {
if (func.constructor !== Function) {
return;
}
_this.getErrorHTML = func;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 51.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.setSuccessHTML = function(func) {
if (func.constructor !== Function) {
return;
}
_this.getSuccessHTML = func;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 51.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid deeply nested control flow statements. Open
} else if (validationGroup) {
groups[validationGroup][ctrl.$name] = false;
// Whenever the element is invalid, we'll check whether one of the elements inside the its group valid or not.
// If there is a valid element, its invalid message won't be shown, Otherwise, shows its invalid message.
Function checkValidation
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
var checkValidation = function(scope, element, attrs, ctrl, validation, value) {
Avoid deeply nested control flow statements. Open
if (validationGroup) {
groups[validationGroup][ctrl.$name] = true;
setValidationGroup(scope, validationGroup, true);
}
Function minlength
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
minlength: function(value, scope, element, attrs, param) {
Function maxlength
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
maxlength: function(value, scope, element, attrs, param) {
Avoid too many return
statements within this function. Open
return valid.error();
Avoid too many return
statements within this function. Open
} else return valid.error();