ezpaarse-project/ezpaarse

View on GitHub

Showing 291 of 291 total issues

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

  var yargs = require('yargs')
    .usage('Execute the scrapers of one or more platforms' +
            '\nUsage: $0 [-alvfc] [Platform] [Platform] ...')
    .alias('help', 'h')
    .alias('all', 'a')
Severity: Major
Found in lib/bin/scrape.js and 1 other location - About 4 hrs to fix
lib/bin/loganonymizer.js on lines 18..31

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

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 data into ezPAARSE and gets the response' +
      '\nUsage: $0')
    .alias('help', 'h')
    .alias('input', 'i')
Severity: Major
Found in lib/bin/loginjector.js and 1 other location - About 4 hrs to fix
lib/bin/csvextractor.js on lines 9..24

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

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

exports.pkbValidator = function () {
  var yargs = require('yargs')
    .usage('Check a platform knowledge base file.' +
      '\n  Usage: $0 [-csvw] pkb_file1.txt [pkb_file2.txt]')
    .boolean(['c', 's', 'v', 'w'])
Severity: Major
Found in lib/bin/pkbvalidator.js - About 4 hrs to fix

    Function pkbValidator has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.pkbValidator = function () {
      var yargs = require('yargs')
        .usage('Check a platform knowledge base file.' +
          '\n  Usage: $0 [-csvw] pkb_file1.txt [pkb_file2.txt]')
        .boolean(['c', 's', 'v', 'w'])
    Severity: Minor
    Found in lib/bin/pkbvalidator.js - About 4 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 processLine has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      this.push = function processLine(line) {
        let isObjectSource = (typeof line === 'object');
        let ec;
    
        if (isObjectSource) {
    Severity: Major
    Found in lib/lineprocessor.js - About 4 hrs to fix

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

      module.exports = function (logFormat, laxist) {
        var usedProperties = [];
        var parameters = {
          'ts':  {property: 'timestamp',            regexp: '([0-9]+)'},
          'tu':  {property: 'subsecond',            regexp: '([0-9]+)'},
      Severity: Minor
      Found in lib/proxyformats/squid.js - About 3 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 exports has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function (options) {
        options = options || {};
      
        let dir;
        if (options.platform) {
      Severity: Major
      Found in lib/pkb-cleaner.js - About 3 hrs to fix

        Function logAnonymizer has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.logAnonymizer = function () {
        
          var Lazy   = require('lazy');
          var faker  = require('@faker-js/faker').faker;
          var fs     = require('fs-extra');
        Severity: Major
        Found in lib/bin/loganonymizer.js - About 3 hrs to fix

          Function pkbManager has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function pkbManager() {
            var knowledge = {};
          
            return {
              /**
          Severity: Major
          Found in lib/pkbmanager.js - About 3 hrs to fix

            Function logFaker has 91 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.logFaker = function (params, callback) {
            
              if (!params) { params = {}; }
            
              var platforms = [];
            Severity: Major
            Found in lib/logfaker.js - About 3 hrs to fix

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

                it('must be able to detect missing header line in pkb file (@01)', function (done) {
                  var testValidatorFile = path.join(__dirname, '/dataset/' + noHeaderLineFile);
                  var child   = spawn('pkbvalidator', [testValidatorFile], { cwd: path.join(__dirname, '/../bin/') });
              
                  child.on('close', function (code) {
              Severity: Major
              Found in test/pkbvalidator-test.js and 1 other location - About 3 hrs to fix
              test/pkbvalidator-test.js on lines 23..31

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

              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

                it('should not crash if parsing a not syntaxicaly valid CSV file (@02)', function (done) {
                  var testValidatorFile = path.join(__dirname, '/dataset/' + invalidSyntax);
                  var child   = spawn('pkbvalidator', [testValidatorFile], { cwd: path.join(__dirname, '/../bin/') });
              
                  child.on('close', function (code) {
              Severity: Major
              Found in test/pkbvalidator-test.js and 1 other location - About 3 hrs to fix
              test/pkbvalidator-test.js on lines 13..21

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

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

              async function getMiddlewaresData() {
                const middlewaresFolder = path.resolve(__dirname, '../middlewares');
                const result = await dbConfig.getConfig('middlewares');
                const savedMiddlewares = result && result.data;
              
              
              Severity: Minor
              Found in routes/info.js - About 3 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 Writer has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              var Writer = function (outputStream, outputFields) {
                var self     = this;
                outputFields = outputFields || [];
              
                outputStream.on('drain', function () {
              Severity: Minor
              Found in lib/outputformats/tsv.js - About 3 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 parseSettings has 88 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function parseSettings (predefined) {
                if (!predefined || !predefined.headers) { return null; }
              
                const settings = JSON.parse(JSON.stringify(defaultSettings));
              
              
              Severity: Major
              Found in client/store/settings.js - About 3 hrs to fix

                File init.js has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                'use strict';
                
                const fs      = require('fs-extra');
                const path    = require('path');
                const winston = require('winston');
                Severity: Minor
                Found in lib/job/init.js - About 3 hrs to fix

                  Function ecmaker has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function ecmaker() {
                    var maker          = {};
                    var uri            = 'http://127.0.0.1:' + config.EZPAARSE_NODEJS_PORT;
                    var requestOptions = {};
                    var resultFile;
                  Severity: Major
                  Found in lib/ecmake.js - About 3 hrs to fix

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

                    function sortObjectR(obj) {
                      var arr = [];
                      for (var prop in obj) {
                        if (obj.hasOwnProperty(prop)) {
                          arr.push({
                    Severity: Major
                    Found in lib/bin/csvtotalizer.js and 1 other location - About 3 hrs to fix
                    lib/bin/csvtotalizer.js on lines 14..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 104.

                    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

                    function sortObject(obj) {
                      var arr = [];
                      for (var prop in obj) {
                        if (obj.hasOwnProperty(prop)) {
                          arr.push({
                    Severity: Major
                    Found in lib/bin/csvtotalizer.js and 1 other location - About 3 hrs to fix
                    lib/bin/csvtotalizer.js on lines 29..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 104.

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

                    module.exports = function (req, res, job, next) {
                      job.logger?.verbose('Initializing EC writer');
                    
                      var acceptEncoding = req.header('response-encoding');
                      var zip;
                    Severity: Minor
                    Found in lib/init/init-writer.js - About 3 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

                    Severity
                    Category
                    Status
                    Source
                    Language