NatLibFi/record-loader-melinda

View on GitHub

Showing 46 of 46 total issues

File melinda.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 *
 * @licstart  The following is the entire license notice for the JavaScript code in this file. 
 *
 * Melinda-related modules for recordLoader
Severity: Minor
Found in lib/record-store/melinda.js - About 2 hrs to fix

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

    module.exports = function(name, argv, console, std_streams)
    {
    
      'use strict';
      
    Severity: Minor
    Found in lib/scripts/merged-records-to-files.js - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

    module.exports = function(name, argv, console, std_streams)
    {
    
      'use strict';
      
    Severity: Major
    Found in lib/scripts/merged-records-to-files.js - About 2 hrs to fix

      Function factory has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function factory(Promise, Object, jsonSimilarity, rankFactory, MarcRecord, processorFactory) {
      
        'use strict';
      
        return function(parameters)
      Severity: Major
      Found in lib/processors/match/melinda.js - About 2 hrs to fix

        Function read has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              read: function(query)
              {
        
                var fn_get_records, fn_get_records_cache;
        
        
        Severity: Minor
        Found in lib/record-store/melinda.js - About 2 hrs to fix

          Function normalizeResults has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function normalizeResults(original_results) {
              var normalized_results = {
                matched: false,
                matchingBundles: [],
                bundleResults: clone(original_results),
          Severity: Minor
          Found in bin/run-host-components-merge.js - About 1 hr to fix

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

            function factory(Object, marc_record_converters, recordSetFactory)
            {
              
              'use strict';
            
            
            Severity: Minor
            Found in lib/hostcomp/record-set/hostcomp.js - About 1 hr to fix

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

                                      function findMissingByIndex(record, index, records)
                                      {
                                          
                                          function getSurroundingRecords()
                                          {
              Severity: Minor
              Found in lib/hostcomp/hooks/related-records-matched/hostcomp.js - About 1 hr to fix

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

                      run: function(record, matched_records)
                      {
                
                        var result;
                
                
                Severity: Minor
                Found in lib/processors/merge/melinda.js - About 1 hr to fix

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

                                              records = records.map(function(record) {
                                                  return Object.assign(record, record.matchedRecords.length > 1 ? {
                                                      failed: true,
                                                      message: 'Multiple matches not allowed'
                                                  } : {});
                  Severity: Major
                  Found in lib/hostcomp/hooks/related-records-matched/hostcomp.js and 1 other location - About 1 hr to fix
                  lib/hostcomp/hooks/related-records-matched/hostcomp.js on lines 255..260

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

                  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

                                              records = records.map(function(record) {
                                                  return Object.assign(record, record.matchedRecords.length === 0 ? {
                                                      failed: true,
                                                      message: 'Records without matches not allowed'
                                                  } : {});
                  Severity: Major
                  Found in lib/hostcomp/hooks/related-records-matched/hostcomp.js and 1 other location - About 1 hr to fix
                  lib/hostcomp/hooks/related-records-matched/hostcomp.js on lines 148..153

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

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

                        update: function(query, record_data)
                        {
                  
                          function process(list, results)
                          {
                  Severity: Minor
                  Found in lib/record-store/melinda.js - About 1 hr to fix

                    Function pump has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function pump(list, results)
                            {
                    
                              var id = list.shift();
                    
                    
                    Severity: Minor
                    Found in lib/record-store/melinda.js - About 1 hr to fix

                      Function run has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            run: function(records_data)
                            {
                      
                              logger.info('Retrieving record store counterpart');
                      
                      
                      Severity: Minor
                      Found in lib/hostcomp/hooks/related-records-retrieved/hostcomp.js - About 1 hr to fix

                        Function factory has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function factory(Promise, Object, MarcRecord, validateFactory, processorFactory) {
                          
                          'use strict';
                          
                          return function(parameters) {
                        Severity: Minor
                        Found in lib/processors/preprocess/melinda.js - About 1 hr to fix

                          Function processBundles has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function processBundles(filenames, result) {
                            var data;
                            var filename = filenames.shift();
                          
                            if (filename) {
                          Severity: Minor
                          Found in bin/run-host-components-merge.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 factory has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function factory(Object, processorFactory) {
                          
                            'use strict';
                          
                            return function(parameters)
                          Severity: Minor
                          Found in lib/hostcomp/processors/match/melinda.js - About 1 hr to fix

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

                            module.exports = function(config) {
                              config.set({
                                singleRun: true,
                                frameworks: ['mocha', 'requirejs'],
                                browsers: ['PhantomJS'],
                            Severity: Minor
                            Found in karma.conf.js - About 1 hr to fix

                              Function factory has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              function factory(Promise, Object, validateFactory, MarcRecord, rankFactory, mergeFactory, processorFactory) {
                              Severity: Major
                              Found in lib/processors/merge/melinda.js - About 50 mins to fix

                                Function factory has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                function factory(Promise, Object, jsonSimilarity, rankFactory, MarcRecord, processorFactory) {
                                Severity: Minor
                                Found in lib/processors/match/melinda.js - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language