ezpaarse-project/ezpaarse

View on GitHub

Showing 291 of 291 total issues

Function readFiles has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    (function readFiles() {
      const file = files[i++];
      if (!file) {
        if (options.rewrite === false) { return e.emit('end'); }
        return rewriteFiles();
Severity: Minor
Found in lib/pkb-cleaner.js - About 1 hr to fix

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

      case 'application/json':
        job.logger?.info('JSON requested for response');
        job.headers['Content-Type'] = 'application/json';
        job.writer = getWriter(getWriterOutputStream('application/json', 'json'), 'json');
    
    
    Severity: Major
    Found in lib/init/init-writer.js and 2 other locations - About 1 hr to fix
    lib/init/init-writer.js on lines 132..138
    lib/init/init-writer.js on lines 153..159

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

    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

        SAVE_CUSTOM_PREDEFINED_SETTINGS (ctx, settings) {
          const { id, fullName, country } = settings;
          return api.saveCustomSettings({
            id,
            fullName,
    Severity: Major
    Found in client/store/settings.js and 1 other location - About 1 hr to fix
    client/store/settings.js on lines 329..337

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

    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

        UPDATE_CUSTOM_PREDEFINED_SETTINGS (ctx, settings) {
          const { id, fullName, country } = settings;
          return api.updateCustomSettings({
            id,
            fullName,
    Severity: Major
    Found in client/store/settings.js and 1 other location - About 1 hr to fix
    client/store/settings.js on lines 320..328

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

    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

      case 'text/csv':
        job.logger?.info('CSV requested for response');
        job.headers['Content-Type'] = 'text/csv';
        job.writer = getWriter(getWriterOutputStream('text/csv', 'csv'), 'csv');
    
    
    Severity: Major
    Found in lib/init/init-writer.js and 2 other locations - About 1 hr to fix
    lib/init/init-writer.js on lines 146..152
    lib/init/init-writer.js on lines 153..159

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

    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

      case 'application/jsonstream':
        job.logger?.info('JSONStream requested for response (one line of JSON per line)');
        job.headers['Content-Type'] = 'application/json';
        job.writer = getWriter(getWriterOutputStream('application/json', 'json'), 'jsonstream');
    
    
    Severity: Major
    Found in lib/init/init-writer.js and 2 other locations - About 1 hr to fix
    lib/init/init-writer.js on lines 132..138
    lib/init/init-writer.js on lines 146..152

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

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

    exports.checkConfig = async function () {
      // get the command line argument
      // platform
      const yargs = require('yargs')
        .usage('Check if ezPAARSE is able to run\nUsage: $0')
    Severity: Minor
    Found in lib/bin/checkconfig.js - About 1 hr to fix

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

        const yargs = require('yargs')
          .usage('Clean knowledge bases.' +
            '\n  Usage: $0 [-nvp] [DIR_TO_CLEAN]')
          .boolean(['n', 'v'])
          .string('p')
      Severity: Major
      Found in lib/bin/pkb-cleaner.js and 1 other location - About 1 hr to fix
      lib/bin/ecmaker.js on lines 11..19

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

      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

        var yargs = require('yargs')
          .usage('Inject a file to ezPAARSE (for batch purpose)' +
            '\n  Usage: $0 [-fhiovH] LOG_FILE RESULT_FILE')
          .boolean(['v', 'f'])
          .string('header')
      Severity: Major
      Found in lib/bin/ecmaker.js and 1 other location - About 1 hr to fix
      lib/bin/pkb-cleaner.js on lines 10..19

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

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

        async function closeStreams() {
          await Promise.all([
            new Promise((resolve, reject) => {
              self.logger?.info('Finalizing report file');
              self.report.finalize(resolve, self.socket);
      Severity: Minor
      Found in lib/job.js - About 1 hr to fix

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

            while (i < 1100) {
              if (i % 8 === 0) { // write about 13% of www.unknowndomain.com
                stream.write(unknownDomainLog + '\n');
              } else {
                stream.write(knownDomainLog + '\n');
        Severity: Major
        Found in test/alerts-test.js and 1 other location - About 1 hr to fix
        test/alerts-test.js on lines 20..27

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

        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

            while (i < 1100) {
              if (i % 8 === 0) { // write about 13% of www.unknowndomain.com
                stream.write(unknownDomainLog + '\n');
              } else {
                stream.write(knownDomainLog + '\n');
        Severity: Major
        Found in test/alerts-test.js and 1 other location - About 1 hr to fix
        test/alerts-test.js on lines 59..66

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

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

        exports.readConfig = function () {
          var config = require('../config.js');
          var pkg    = require('../../package.json');
        
        
        
        Severity: Minor
        Found in lib/bin/readconfig.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

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

          describe('a basic log file with an operator-less field in Output-Fields header', () => {
            it('should have closed all the used file descriptors (@04)', (done) => {
              const log = path.resolve(__dirname, '/dataset/sd.mini.log');
              processLogAndTestLsof(log, { 'Output-Fields' : '-url,newCol' }, done);
            }).timeout(10000);
        Severity: Major
        Found in test/lsof-test.js and 2 other locations - About 1 hr to fix
        test/lsof-test.js on lines 22..27
        test/lsof-test.js on lines 29..34

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

        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

          describe('a log file with an unsupported output format requested', () => {
            it('should have closed all the used file descriptors (@02)', (done) => {
              const log = path.resolve(__dirname, '/dataset/sd.mini.log');
              processLogAndTestLsof(log, { 'Accept': 'unsupported/format' }, done);
            }).timeout(10000);
        Severity: Major
        Found in test/lsof-test.js and 2 other locations - About 1 hr to fix
        test/lsof-test.js on lines 29..34
        test/lsof-test.js on lines 36..41

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

        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

          describe('a basic log file with an empty field in the Output-Fields header', () => {
            it('should have closed all the used file descriptors (@03)', (done) => {
              const log = path.resolve(__dirname, '/dataset/sd.mini.log');
              processLogAndTestLsof(log, { 'Output-Fields' : ',+newCol' }, done);
            }).timeout(10000);
        Severity: Major
        Found in test/lsof-test.js and 2 other locations - About 1 hr to fix
        test/lsof-test.js on lines 22..27
        test/lsof-test.js on lines 36..41

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

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

        ReportManager.prototype.compute = function () {
          var nbRejects     = this.get('rejets', 'nb-lines-unknown-formats');
          nbRejects        += this.get('rejets', 'nb-lines-unknown-domains');
          nbRejects        += this.get('rejets', 'nb-lines-unqualified-ecs');
          nbRejects        += this.get('rejets', 'nb-lines-unknown-errors');
        Severity: Minor
        Found in lib/reportmanager.js - About 1 hr to fix

          Function processLogAndTestLsof has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function processLogAndTestLsof(log, headers, done) {
              let lsofBefore  = [];
              let lsofAfter   = [];
              lsof.raw(ezpaarsePid, (data) => {
                lsofBefore = data.filter(filterTypes);
          Severity: Minor
          Found in test/lsof-test.js - About 1 hr to fix

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

            module.exports = function (req, res, job, next) {
              job.logger?.verbose('Initializing alerts');
            
              var match;
              var actions       = req.header('ezPAARSE-Job-Notifications');
            Severity: Minor
            Found in lib/init/init-alerts.js - About 1 hr to fix

              Function isValid has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.isValid = function (ec, job) {
                const validCodes = new Set(['200', '304']);
                const deniedCodes = new Set(['401', '403']);
                const filterRedirs = job.hasOwnProperty('filterRedirs') ? job.filterRedirs : true;
                const filterStatus = job.hasOwnProperty('filterStatus') ? job.filterStatus : true;
              Severity: Minor
              Found in lib/ecfilter.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language