NatLibFi/marc-record-serializers

View on GitHub

Showing 45 of 81 total issues

Function to has a Cognitive Complexity of 186 (exceeds 5 allowed). Consider refactoring.
Open

export function to(record, useCrForContinuingResource = false) {

  const MAX_FIELD_LENGTH = 2000;
  const SPLIT_MAX_FIELD_LENGTH = 1000;

Severity: Minor
Found in src/aleph-sequential.js - About 3 days 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 to has 261 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function to(record, useCrForContinuingResource = false) {

  const MAX_FIELD_LENGTH = 2000;
  const SPLIT_MAX_FIELD_LENGTH = 1000;

Severity: Major
Found in src/aleph-sequential.js - About 1 day to fix

    Function from has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

    export function from(dataStr, validationOptions = {}) {
      const leader = dataStr.substring(0, 24);
      const record = {
        leader,
        fields: []
    Severity: Minor
    Found in src/iso2709.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

    File aleph-sequential.js has 466 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable max-lines */
    /**
    *
    * @licstart  The following is the entire license notice for the JavaScript code in this file.
    *
    Severity: Minor
    Found in src/aleph-sequential.js - About 7 hrs to fix

      Function formatDatafield has 168 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function formatDatafield(field) {
          let subfieldLines; // eslint-disable-line functional/no-let
          const ind1 = field.ind1 && field.ind1.length > 0 ? field.ind1 : ' ';
          const ind2 = field.ind2 && field.ind2.length > 0 ? field.ind2 : ' ';
          const header = `${id} ${field.tag}${ind1}${ind2} L `;
      Severity: Major
      Found in src/aleph-sequential.js - About 6 hrs to fix

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

        async function run() {
          const VALIDATION_OPTIONS_USAGE = `Validation options:
          111 => {fields: true, subfields: true, subfieldValues: true}
          010 => {fields: false, subfields: true, subfieldValues: false}
          000 => {fields: false, subfields: false, subfieldValues: false}`;
        Severity: Major
        Found in src/cli.js - About 6 hrs to fix

          Function reduceToLines has 144 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function reduceToLines(result, subfield, index, arr) {
                let code; // eslint-disable-line functional/no-let
                let sliceOffset; // eslint-disable-line functional/no-let
                let slicedSegment; // eslint-disable-line functional/no-let
                const tempLength = result.temp ? result.temp.length : 0;
          Severity: Major
          Found in src/aleph-sequential.js - About 5 hrs to fix

            Function from has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
            Open

            export function from(data, validationOptions = {}) {
              let i = 0; // eslint-disable-line functional/no-let
              const lines = data.split('\n').filter(l => l.length > 0);
            
              // eslint-disable-next-line functional/no-loop-statements
            Severity: Minor
            Found in src/aleph-sequential.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 iterate has 110 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  function iterate(segment, firstCall) {
                    const HYPHEN = 45;
                    const SPACE = 32;
                    const CARET = 94;
                    const DOLLAR = 36;
            Severity: Major
            Found in src/aleph-sequential.js - About 4 hrs to fix

              Function from has 109 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function from(data, validationOptions = {}) {
                let i = 0; // eslint-disable-line functional/no-let
                const lines = data.split('\n').filter(l => l.length > 0);
              
                // eslint-disable-next-line functional/no-loop-statements
              Severity: Major
              Found in src/aleph-sequential.js - About 4 hrs to fix

                Function from has 107 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function from(dataStr, validationOptions = {}) {
                  const leader = dataStr.substring(0, 24);
                  const record = {
                    leader,
                    fields: []
                Severity: Major
                Found in src/iso2709.js - About 4 hrs to fix

                  Function reader has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function reader(stream, validationOptions = {}, genF001fromSysNo = false) {
                  
                    const emitter = new class extends EventEmitter { }();
                    start();
                    return emitter;
                  Severity: Major
                  Found in src/aleph-sequential.js - About 3 hrs to fix

                    Function getSliceOffset has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function getSliceOffset(arr) {
                              const offset = findSeparatorOffset(arr) || findPeriodOffset(arr) || findSpaceOffset(arr) || SPLIT_MAX_FIELD_LENGTH;
                    
                              return offset;
                    
                    
                    Severity: Major
                    Found in src/aleph-sequential.js - About 3 hrs to fix

                      Function start has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function start() {
                      
                          let charbuffer = ''; // eslint-disable-line functional/no-let
                          const linebuffer = []; // eslint-disable-line functional/no-let
                          let count = 0; // eslint-disable-line functional/no-let
                      Severity: Major
                      Found in src/aleph-sequential.js - About 3 hrs to fix

                        Function run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function run() {
                          const VALIDATION_OPTIONS_USAGE = `Validation options:
                          111 => {fields: true, subfields: true, subfieldValues: true}
                          010 => {fields: false, subfields: true, subfieldValues: false}
                          000 => {fields: false, subfields: false, subfieldValues: false}`;
                        Severity: Minor
                        Found in src/cli.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 from has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function from(xmlString, validationOptions = {}) {
                          const parser = new DOMParser();
                          const record = new MarcRecord();
                        
                          debug(`Parsing from xmlstring`);
                        Severity: Major
                        Found in src/oai-marcxml.js - About 2 hrs to fix

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

                          export function to(record) {
                          
                            //let tag; // eslint-disable-line functional/no-let
                            //let ind1; // eslint-disable-line functional/no-let
                            //let ind2; // eslint-disable-line functional/no-let
                          Severity: Major
                          Found in src/iso2709.js - About 2 hrs to fix

                            Function reader has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function reader(stream, validationOptions = {}) {
                            
                              const emitter = new class extends EventEmitter { }();
                              start();
                              return emitter;
                            Severity: Minor
                            Found in src/text.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 getService has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              function getService(type) {
                                if (type === 'text') {
                                  return {
                                    reader: Text.reader,
                                    serialize: Text.to,
                            Severity: Major
                            Found in src/cli.js - About 2 hrs to fix

                              Function reader has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function reader(stream, validationOptions = {}) {
                              
                                const emitter = new class extends EventEmitter { }();
                                start();
                                return emitter;
                              Severity: Minor
                              Found in src/text.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language