timbeadle/grunt-tv4

View on GitHub

Showing 32 of 32 total issues

Function exports has 388 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (grunt) {
    // Load all npm grunt tasks
    require('load-grunt-tasks')(grunt);

    grunt.loadTasks('tasks');
Severity: Major
Found in Gruntfile.js - About 1 day to fix

    Function getRunner has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

    const getRunner = (tv4, loader, out, style) => {
    
        const getContext = (options) => {
            const context = {};
            context.tv4 = (options.fresh ? tv4.freshApi() : tv4);
    Severity: Minor
    Found in lib/runner.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 getRunner has 238 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getRunner = (tv4, loader, out, style) => {
    
        const getContext = (options) => {
            const context = {};
            context.tv4 = (options.fresh ? tv4.freshApi() : tv4);
    Severity: Major
    Found in lib/runner.js - About 1 day to fix

      File Gruntfile.js has 391 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
       * Grunt wrapper for tv4 - grunt-tv4
       * https://github.com/timbeadle/grunt-tv4
       *
       * Copyright (c) 2013 Bart van der Schoor
      Severity: Minor
      Found in Gruntfile.js - About 5 hrs to fix

        File runner.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-disable unicorn/prefer-module, no-warning-comments, node/prefer-global/process */
        // Bulk validation core: composites with tv4, miniwrite, ministyle and loaders
        
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
        
        Severity: Minor
        Found in lib/runner.js - About 3 hrs to fix

          Function exports has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = (grunt) => {
          
              const out = miniwrite.grunt(grunt);
              const style = ministyle.grunt();
              const report = reporter.getReporter(out, style);
          Severity: Major
          Found in tasks/tv4.js - About 3 hrs to fix

            Function doValidateObject has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const doValidateObject = (job, object, callback) => {
                    if (!object.root) {
                        // TODO handle this better
                        job.error = new Error('no explicit root schema');
            
            
            Severity: Minor
            Found in lib/runner.js - About 1 hr to fix

              Function exports has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function (grunt) {
                  // Load all npm grunt tasks
                  require('load-grunt-tasks')(grunt);
              
                  grunt.loadTasks('tasks');
              Severity: Minor
              Found in Gruntfile.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 getContext has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  const getContext = (options) => {
                      const context = {};
                      context.tv4 = (options.fresh ? tv4.freshApi() : tv4);
                      context.options = {};
              
              
              Severity: Minor
              Found in lib/runner.js - About 1 hr to fix

                Function recursiveTest has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const recursiveTest = (job, object, callback) => {
                        const { options } = job.context;
                        if (job.context.options.multi) {
                            object.result = job.context.tv4.validateMultiple(
                                object.value,
                Severity: Minor
                Found in lib/runner.js - About 1 hr to fix

                  Function loadHTTP has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const loadHTTP = (uri, options, callback) => {
                      const options_ = {
                          timeout: options ? options.timeout : 5000
                      };
                  
                  
                  Severity: Minor
                  Found in lib/loader.js - About 1 hr to fix

                    Function loadSchemaList has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        const loadSchemaList = (job, uris, callback) => {
                            uris = uris.filter((value) => {
                                return Boolean(value);
                            });
                    
                    
                    Severity: Minor
                    Found in lib/runner.js - About 1 hr to fix

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

                              if (object.result.missing.length === 0) {
                                  job.passed.push(object);
                                  out.writeln('> ' + style.success('pass') + ' | ' + tweakURI(object.label));
                      
                                  return callback();
                      Severity: Major
                      Found in lib/runner.js and 1 other location - About 1 hr to fix
                      lib/runner.js on lines 286..291

                      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 64.

                      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

                              if (!object.result.valid) {
                                  job.failed.push(object);
                                  out.writeln('> ' + style.error('fail') + ' - ' + tweakURI(object.label));
                      
                                  return callback();
                      Severity: Major
                      Found in lib/runner.js and 1 other location - About 1 hr to fix
                      lib/runner.js on lines 293..298

                      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 64.

                      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 copyProps has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const copyProps = (target, source, recursive) => {
                          if (source) {
                              const sourceKeys = Object.keys(source);
                              for (const key of sourceKeys) {
                                  if (recursive && typeof source[key] === 'object') {
                      Severity: Minor
                      Found in lib/runner.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

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

                                      options: {
                                          fresh: true,
                                          root: grunt.file.readJSON('test/fixtures/bulk/schema/schema.json'),
                                          add: [
                                              grunt.file.readJSON('test/fixtures/bulk/schema/alpha.json'),
                      Severity: Major
                      Found in Gruntfile.js and 1 other location - About 1 hr to fix
                      Gruntfile.js on lines 231..238

                      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 60.

                      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

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

                                      options: {
                                          fresh: true,
                                          root: grunt.file.readJSON('test/fixtures/bulk/schema/schema.json'),
                                          add: [
                                              grunt.file.readJSON('test/fixtures/bulk/schema/alpha.json'),
                      Severity: Major
                      Found in Gruntfile.js and 1 other location - About 1 hr to fix
                      Gruntfile.js on lines 277..284

                      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 60.

                      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

                              grunt.util._.each(context.options.schemas, (schema, uri) => {
                                  context.tv4.addSchema(uri, schema);
                              });
                      Severity: Minor
                      Found in tasks/tv4.js and 1 other location - About 50 mins to fix
                      tasks/tv4.js on lines 53..55

                      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

                      Further Reading

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

                              grunt.util._.each(context.options.languages, (language, id) => {
                                  context.tv4.addLanguage(id, language);
                              });
                      Severity: Minor
                      Found in tasks/tv4.js and 1 other location - About 50 mins to fix
                      tasks/tv4.js on lines 47..49

                      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

                      Further Reading

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

                              if (job.context.options.multi) {
                                  object.result = job.context.tv4.validateMultiple(
                                      object.value,
                                      object.schema,
                                      options.checkRecursive,
                      Severity: Minor
                      Found in lib/runner.js and 1 other location - About 40 mins to fix
                      lib/runner.js on lines 276..283

                      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 49.

                      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