NatLibFi/marc-record-validators-melinda

View on GitHub
src/reindexSubfield6OccurenceNumbers.js

Summary

Maintainability
B
6 hrs
Test Coverage

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

function recordDisambiguateSharedSubfield6OccurrenceNumbers(record) {
  const sharedOccurrenceNumberFields = recordGetSharedOccurrenceNumbers(record);
  if (sharedOccurrenceNumberFields.length < 2) {
    return;
  }
Severity: Minor
Found in src/reindexSubfield6OccurenceNumbers.js - About 1 hr to fix

    Function recordDisambiguateSharedSubfield6OccurrenceNumbers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function recordDisambiguateSharedSubfield6OccurrenceNumbers(record) {
      const sharedOccurrenceNumberFields = recordGetSharedOccurrenceNumbers(record);
      if (sharedOccurrenceNumberFields.length < 2) {
        return;
      }
    Severity: Minor
    Found in src/reindexSubfield6OccurenceNumbers.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 recordResetSubfield6OccurrenceNumbers has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function recordResetSubfield6OccurrenceNumbers(record) { // Remove gaps
      /* eslint-disable */
      let currentInt = 1;
      let oldtoNewCache = {};
    
    
    Severity: Minor
    Found in src/reindexSubfield6OccurenceNumbers.js - About 1 hr to fix

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

      export default function () {
        return {
          description: 'Reindex occurrence numbers in $6 subfield so that they start from 01 and end in NN',
          validate, fix
        };
      Severity: Minor
      Found in src/reindexSubfield6OccurenceNumbers.js - About 1 hr to fix

        Function recordResetSubfield6OccurrenceNumbers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function recordResetSubfield6OccurrenceNumbers(record) { // Remove gaps
          /* eslint-disable */
          let currentInt = 1;
          let oldtoNewCache = {};
        
        
        Severity: Minor
        Found in src/reindexSubfield6OccurenceNumbers.js - About 55 mins 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

        Avoid too many return statements within this function.
        Open

            return true;
        Severity: Major
        Found in src/reindexSubfield6OccurenceNumbers.js - About 30 mins to fix

          Function recordGetNumberOfUniqueSubfield6OccurrenceNumbers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function recordGetNumberOfUniqueSubfield6OccurrenceNumbers(record) {
            // Calculates the number of used different occurrence numbers
            /* eslint-disable */
            let indexArray = [];
            record.fields.forEach(field => gatherFieldData(field));
          Severity: Minor
          Found in src/reindexSubfield6OccurenceNumbers.js - About 25 mins 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

          There are no issues that match your filters.

          Category
          Status