NatLibFi/marc-record-serializers

View on GitHub

Showing 45 of 81 total issues

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

export function reader (stream, validationOptions = {}, nameSpace = '') {
  const emitter = new class extends EventEmitter { }();
  const nameSpacePrefix = nameSpace === '' ? nameSpace : `${nameSpace}:`;

  MarcRecord.setValidationOptions(validationOptions);
Severity: Minor
Found in src/marcxml.js - About 1 hr to fix

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

    export function to(record, {omitDeclaration = false, indent = false} = {}) {
      const obj = {
        record: {
          ...generateFields(),
          $: {
    Severity: Minor
    Found in src/marcxml.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 start has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function start() {
    
        MarcRecord.setValidationOptions(validationOptions);
        var buffer = ''; // eslint-disable-line
    
    
    Severity: Minor
    Found in src/text.js - About 1 hr to fix

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

      export function reader(stream, validationOptions = {}) {
        const emitter = new class extends EventEmitter { }();
        MarcRecord.setValidationOptions(validationOptions);
      
        start();
      Severity: Minor
      Found in src/oai-marcxml.js - About 1 hr to fix

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

        export async function from(str, validationOptions = {}) {
          const record = new MarcRecord(undefined, validationOptions);
          const obj = await toObject();
        
          // eslint-disable-next-line functional/immutable-data
        Severity: Minor
        Found in src/marcxml.js - About 1 hr to fix

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

            function start() {
              // eslint-disable-next-line functional/no-let
              let charbuffer = '';
          
              stream.on('end', () => {
          Severity: Minor
          Found in src/marcxml.js - About 1 hr to fix

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

              function parseFieldFromLine(lineStr) {
                const tag = lineStr.substring(10, 13);
            
                if (tag === undefined || tag.length !== 3) {
                  throw new Error(`Could not parse tag from line: ${lineStr}`);
            Severity: Minor
            Found in src/aleph-sequential.js - About 1 hr to fix

              Function recordFormat has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function recordFormat(record, useCrForContinuingResource) {
                  const {leader} = record;
                  const l6 = leader.slice(6, 7);
                  const l7 = leader.slice(7, 8);
              
              
              Severity: Minor
              Found in src/aleph-sequential.js - About 1 hr to fix

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

                  function start() {
                
                    let charbuffer = ''; // eslint-disable-line functional/no-let
                
                    stream.on('end', () => {
                Severity: Minor
                Found in src/oai-marcxml.js - About 1 hr to fix

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

                    function generateFields() {
                      return {
                        leader: [record.leader],
                        controlfield: record.getControlfields().map(({value: _, tag}) => {
                          if (_) {
                  Severity: Minor
                  Found in src/marcxml.js - About 1 hr to fix

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

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

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

                      function utf8Substr(str, startInBytes, lengthInBytes) {
                        const strBytes = stringToByteArray(str);
                        const subStrBytes = [];
                        let count = 0; // eslint-disable-line functional/no-let
                      
                      
                      Severity: Minor
                      Found in src/iso2709.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 findPeriodOffset has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                function findPeriodOffset(arr) {
                                  let offset = find(); // eslint-disable-line functional/no-let
                      
                                  if (offset !== undefined) {
                                    // Append the number of chars in separator
                      Severity: Minor
                      Found in src/aleph-sequential.js - About 1 hr to fix

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

                                  function findSeparatorOffset(arr) {
                        
                                    let offset = find(); // eslint-disable-line functional/no-let
                        
                                    if (offset !== undefined) {
                        Severity: Minor
                        Found in src/aleph-sequential.js - About 1 hr to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    if (currElementStr !== '') { // eslint-disable-line max-depth
                                      // eslint-disable-next-line functional/no-conditional-statements
                                      if (j === dataElementStr.length - 1) { // eslint-disable-line max-depth
                                        currElementStr += dataElementStr.charAt(j);
                                      }
                          Severity: Major
                          Found in src/iso2709.js - About 45 mins to fix

                            Function stringToByteArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function stringToByteArray(str) {
                              const byteArray = [];
                            
                              // eslint-disable-next-line functional/no-loop-statements, functional/no-let, no-plusplus
                              for (let i = 0; i < str.length; i++) {
                            Severity: Minor
                            Found in src/iso2709.js - About 35 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 'MP';
                            Severity: Major
                            Found in src/aleph-sequential.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    return 'SE';
                              Severity: Major
                              Found in src/aleph-sequential.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

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

                                  Avoid too many return statements within this function.
                                  Open

                                        return 'MU';
                                  Severity: Major
                                  Found in src/aleph-sequential.js - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language