Showing 27 of 27 total issues
Function MoxBuilder
has 287 lines of code (exceeds 25 allowed). Consider refactoring. Open
function MoxBuilder() {
var
moduleNames,
moduleFns,
File helpers-spec.js
has 566 lines of code (exceeds 250 allowed). Consider refactoring. Open
describe('The helper functions', function () {
describe('Test helpers', function () {
beforeEach(function () {
angular.module('mox').value('x', 1).value('y', 2);
File mox-spec.js
has 556 lines of code (exceeds 250 allowed). Consider refactoring. Open
angular.extend(moxConfig, {
factory2: mox.createMock('factory2', ['methodA']),
factory3: function ($provide, mock) {
$provide.value('factory3', mock);
}
Function MoxBuilder
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
function MoxBuilder() {
var
moduleNames,
moduleFns,
- 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 requestTest
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
function requestTest() {
var test = {
_httpMethod: 'GET',
_data: null
};
Function exports
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
var paths = {
src: 'src',
File mox.js
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
var moxConfig = {};
angular.module('mox', [])
.service('Mox', MoxBuilder);
var mox = angular.injector(['mox']).get('Mox');
Similar blocks of code found in 3 locations. Consider refactoring. Open
it('should set the httpMethod DELETE and path', function () {
var test = requestTest().expectDelete('path', 'data');
expect(test._httpMethod).toBe('DELETE');
expect(test._path).toBe('path');
expect(test._data).toBe('data');
- 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 89.
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 3 locations. Consider refactoring. Open
it('should set the httpMethod POST, with data and path', function () {
var test = requestTest().expectPost('path', 'data');
expect(test._httpMethod).toBe('POST');
expect(test._path).toBe('path');
expect(test._data).toBe('data');
- 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 89.
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 3 locations. Consider refactoring. Open
it('should set the httpMethod PUT, with data and path', function () {
var test = requestTest().expectPut('path', 'data');
expect(test._httpMethod).toBe('PUT');
expect(test._path).toBe('path');
expect(test._data).toBe('data');
- 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 89.
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 requestTest
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function requestTest() {
var test = {
_httpMethod: 'GET',
_data: null
};
- 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 mockServices
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.mockServices = function mockServices() {
function getMethodNames(obj) {
var methodNames = [];
angular.forEach(obj, function (method, methodName) {
if (angular.isFunction(method)) {
Function addSelectors
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function addSelectors(element, selectors) {
function checkAndSetFn(obj, prop, fn) {
var property = obj[prop];
if (angular.isUndefined(property)) {
- 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 addSelectors
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addSelectors(element, selectors) {
function checkAndSetFn(obj, prop, fn) {
var property = obj[prop];
if (angular.isUndefined(property)) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
expect(resourceResult(resourceData).$promise).toResolveWith(function (result) {
expect(result).not.toBe(resourceData);
expect(result).not.toEqual(resourceData);
expect(result).toEqual(_.omit(resourceData, '$save'));
});
- 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 70.
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
expect(promise(resolve)).toResolveWith(function (result) {
expect(result).not.toBe(resolve);
expect(result).not.toEqual(resolve);
expect(result).toEqual(_.omit(resolve, '$save'));
});
- 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 70.
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 setupResults
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.setupResults = function setupResults(configFn) {
postInjectFns.push(function setupResultsFn() {
var config = configFn();
angular.forEach(config, function (mockConfig, mockName) {
var mock = mox.inject(mockName);
Function setupResultsFn
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
postInjectFns.push(function setupResultsFn() {
var config = configFn();
angular.forEach(config, function (mockConfig, mockName) {
var mock = mox.inject(mockName);
if (!(mockName in mox.get)) {
Function run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
test.run = function run() {
test._response = test._response || {};
mox.inject('$httpBackend').expect(test._httpMethod, { test: validateUrl }, test._data).respond(test._response);
var response = test._method.apply(this, test._methodArguments);
Similar blocks of code found in 2 locations. Consider refactoring. Open
it('should setup a fake method for the spy object spy', function () {
setupResults()();
expect(mox.get.factory.methodB()).toBe('mockResult B');
});
- 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 52.
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