ezpaarse-project/ezpaarse

View on GitHub

Showing 291 of 291 total issues

Function Job has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

function Job(req, res, jobID, options) {
  const self = ezJobs[jobID] = this;
  req._jobID = jobID;

  io().in('admin').emit('jobs', Object.keys(ezJobs));
Severity: Minor
Found in lib/job.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 exports has 214 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function () {
  var currentCompletion;
  var possibleFields = {};

  var rl = readline.createInterface({
Severity: Major
Found in lib/bin/platform-init.js - About 1 day to fix

    Function LinesProcessor has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

    const LinesProcessor = function (job) {
      let ecNumber   = 0;
      let nbBadLines = 0;
      let firstLine  = true;
      const emit = this.emit.bind(this);
    Severity: Minor
    Found in lib/lineprocessor.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

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

          helpers.post('/', logFile, headers, function (err, res, body) {
            if (!res) { throw new Error('ezPAARSE is not running'); }
            if (err)  { throw err; }
            res.should.have.status(200);
    
    
    Severity: Major
    Found in test/injection-incsv-test.js and 1 other location - About 1 day to fix
    test/injection-inraw-outjson-test.js on lines 21..39

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

    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

          helpers.post('/', logFile, headers, function (err, res, body) {
            if (!res) { throw new Error('ezPAARSE is not running'); }
            if (err)  { throw err; }
            res.should.have.status(200);
    
    
    Severity: Major
    Found in test/injection-inraw-outjson-test.js and 1 other location - About 1 day to fix
    test/injection-incsv-test.js on lines 22..40

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

    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 LinesProcessor has 204 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const LinesProcessor = function (job) {
      let ecNumber   = 0;
      let nbBadLines = 0;
      let firstLine  = true;
      const emit = this.emit.bind(this);
    Severity: Major
    Found in lib/lineprocessor.js - About 1 day to fix

      Function ridChecker has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
      Open

      var ridChecker = function () {
        var self = this;
        var DoNotCheckPattern = new RegExp('^#');
        var ISSNPattern = new RegExp('[0-9]{4}\\-[0-9]{3}([0-9Xx])?');
        var ISBNPattern = new RegExp('((978[-– ])?[0-9][0-9-– ]{10}[-– ][0-9xX])|((978)?[0-9]{9}[0-9])');
      Severity: Minor
      Found in lib/rid-syntax-checker.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

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

          helpers.get(reportURL, function (error, response, reportBody) {
            if (!response) { throw new Error('ezPAARSE is not running'); }
            if (error)     { throw error; }
            response.statusCode.should.equal(200,
              'failed to get the report, server responded with a code ' + response.statusCode);
      Severity: Major
      Found in test/sudoc-test.js and 3 other locations - About 7 hrs to fix
      test/crossref-aggregate-test.js on lines 36..49
      test/crossref-test.js on lines 36..49
      test/hal-test.js on lines 32..46

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

      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 4 locations. Consider refactoring.
      Open

            helpers.get(reportURL, function (error, response, reportBody) {
              if (!response) { throw new Error('ezPAARSE is not running'); }
              if (error)     { throw error; }
              response.statusCode.should.equal(200,
                'failed to get the report, server responded with a code ' + response.statusCode);
      Severity: Major
      Found in test/crossref-test.js and 3 other locations - About 7 hrs to fix
      test/crossref-aggregate-test.js on lines 36..49
      test/hal-test.js on lines 32..46
      test/sudoc-test.js on lines 33..46

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

      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 4 locations. Consider refactoring.
      Open

            helpers.get(reportURL, function (error, response, reportBody) {
              if (!response) { throw new Error('ezPAARSE is not running'); }
              if (error)     { throw error; }
              response.statusCode.should.equal(200,
                'failed to get the report, server responded with a code ' + response.statusCode);
      Severity: Major
      Found in test/crossref-aggregate-test.js and 3 other locations - About 7 hrs to fix
      test/crossref-test.js on lines 36..49
      test/hal-test.js on lines 32..46
      test/sudoc-test.js on lines 33..46

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

      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 4 locations. Consider refactoring.
      Open

            helpers.get(reportURL, function (error, response, reportBody) {
              if (!response) { throw new Error('ezPAARSE is not running'); }
              if (error)     { throw error; }
              response.statusCode.should.equal(200,
                'failed to get the report, server responded with a code ' + response.statusCode);
      Severity: Major
      Found in test/hal-test.js and 3 other locations - About 7 hrs to fix
      test/crossref-aggregate-test.js on lines 36..49
      test/crossref-test.js on lines 36..49
      test/sudoc-test.js on lines 33..46

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

      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

      module.exports = function (req, res, job, next) {
        job.logger?.verbose('Initializing git platforms values');
      
        git.short({ cwd: path.join(__dirname, '..', '..', 'platforms') }, function (err, str) {
          if (str) { job.report.set('general', 'platforms-version', `${str}` || 'N/A'); }
      Severity: Major
      Found in lib/init/init-platforms.js and 1 other location - About 7 hrs to fix
      lib/init/init-middlewares.js on lines 13..26

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

      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

      module.exports = function (req, res, job, next) {
        job.logger?.verbose('Initializing git middlewares values');
      
        git.short({ cwd: path.join(__dirname, '..', '..', 'middlewares') }, function (err, str) {
          if (str) { job.report.set('general', 'middlewares-version', `${str}` || 'N/A'); }
      Severity: Major
      Found in lib/init/init-middlewares.js and 1 other location - About 7 hrs to fix
      lib/init/init-platforms.js on lines 13..25

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

      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

      app.get('/countries.json', function (req, res, next) {
        const countriesFile = path.resolve(__dirname, '../resources/countries.json');
      
        fs.readFile(countriesFile, function (err, data) {
          if (err) {
      Severity: Major
      Found in routes/info.js and 1 other location - About 7 hrs to fix
      routes/info.js on lines 487..507

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

      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

      app.get('/predefined-settings', function (req, res, next) {
        const settingsFile = path.join(__dirname, '/../resources/predefined-settings.json');
      
        fs.readFile(settingsFile, function (err, data) {
          if (err) {
      Severity: Major
      Found in routes/info.js and 1 other location - About 7 hrs to fix
      routes/info.js on lines 462..482

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

      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 Job has 175 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Job(req, res, jobID, options) {
        const self = ezJobs[jobID] = this;
        req._jobID = jobID;
      
        io().in('admin').emit('jobs', Object.keys(ezJobs));
      Severity: Major
      Found in lib/job.js - About 7 hrs to fix

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

          describe('receives a log on the HTTP POST / route with an '
          + 'operator-less field in Output-Fields header', function () {
            it('and sends back a 4013 error code (@04)', function (done) {
              var headers = {
                'Output-Fields' : '-url,newCol'
        Severity: Major
        Found in test/custom-fields-test.js and 1 other location - About 6 hrs to fix
        test/custom-fields-test.js on lines 73..92

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

        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

          describe('receives a log on the HTTP POST / route with an '
          + ' empty field in Output-Fields header', function () {
            it('and sends back a 4012 error code (@03)', function (done) {
              var headers = {
                'Output-Fields' : ',+newCol'
        Severity: Major
        Found in test/custom-fields-test.js and 1 other location - About 6 hrs to fix
        test/custom-fields-test.js on lines 93..112

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

        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 EcBulkMaker has 167 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.EcBulkMaker = function () {
        
          var yargs = require('yargs')
            .usage('Inject files to ezPAARSE (for batch purpose)' +
              '\n  Usage: $0 [-rflvH] SOURCE_DIR [RESULT_DIR]')
        Severity: Major
        Found in lib/bin/ecbulkmaker.js - About 6 hrs to fix

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

            describe('receives a non-gzipped log file with a gzip content-encoding', function () {
              it('and sends back a JSON with an error 4002 (@03)', function (done) {
                var headers = {
                  'content-encoding': 'gzip'
                };
          Severity: Major
          Found in test/injectionerrors-test.js and 2 other locations - About 6 hrs to fix
          test/injectionerrors-test.js on lines 49..68
          test/injectionerrors-test.js on lines 69..88

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

          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