fvanwijk/mox

View on GitHub

Showing 27 of 27 total issues

Function MoxBuilder has 287 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function MoxBuilder() {

  var
    moduleNames,
    moduleFns,
Severity: Major
Found in src/mox.js - About 1 day to fix

    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);
    Severity: Major
    Found in test/spec/helpers-spec.js - About 1 day to fix

      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);
        }
      Severity: Major
      Found in test/spec/mox-spec.js - About 1 day to fix

        Function MoxBuilder has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
        Open

        function MoxBuilder() {
        
          var
            moduleNames,
            moduleFns,
        Severity: Minor
        Found in src/mox.js - About 1 day to fix

        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
          };
        Severity: Major
        Found in src/helpers.js - About 3 hrs to fix

          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',
          Severity: Major
          Found in Gruntfile.js - About 3 hrs to fix

            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');
            Severity: Minor
            Found in src/mox.js - About 3 hrs to fix

              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');
              Severity: Major
              Found in test/spec/helpers-spec.js and 2 other locations - About 2 hrs to fix
              test/spec/helpers-spec.js on lines 545..550
              test/spec/helpers-spec.js on lines 552..557

              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

              Further Reading

              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');
              Severity: Major
              Found in test/spec/helpers-spec.js and 2 other locations - About 2 hrs to fix
              test/spec/helpers-spec.js on lines 552..557
              test/spec/helpers-spec.js on lines 559..564

              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

              Further Reading

              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');
              Severity: Major
              Found in test/spec/helpers-spec.js and 2 other locations - About 2 hrs to fix
              test/spec/helpers-spec.js on lines 545..550
              test/spec/helpers-spec.js on lines 559..564

              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

              Further Reading

              Function requestTest has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              function requestTest() {
                var test = {
                  _httpMethod: 'GET',
                  _data: null
                };
              Severity: Minor
              Found in src/helpers.js - About 2 hrs to fix

              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)) {
              Severity: Major
              Found in src/mox.js - About 2 hrs to fix

                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)) {
                Severity: Minor
                Found in src/helpers.js - About 1 hr to fix

                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)) {
                Severity: Minor
                Found in src/helpers.js - About 1 hr to fix

                  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'));
                            });
                  Severity: Major
                  Found in test/spec/helpers-spec.js and 1 other location - About 1 hr to fix
                  test/spec/helpers-spec.js on lines 189..193

                  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

                  Further Reading

                  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'));
                            });
                  Severity: Major
                  Found in test/spec/helpers-spec.js and 1 other location - About 1 hr to fix
                  test/spec/helpers-spec.js on lines 232..236

                  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

                  Further Reading

                  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);
                  Severity: Minor
                  Found in src/mox.js - About 1 hr to fix

                    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)) {
                    Severity: Minor
                    Found in src/mox.js - About 1 hr to fix

                      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);
                      Severity: Minor
                      Found in src/helpers.js - About 1 hr to fix

                        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');
                            });
                        Severity: Minor
                        Found in test/spec/mox-spec.js and 1 other location - About 50 mins to fix
                        test/spec/mox-spec.js on lines 516..519

                        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

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language