petuomin/marc-record-js

View on GitHub
lib/MarcRecord.js

Summary

Maintainability
F
3 days
Test Coverage

Function Record has 241 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function Record(rec) {

    var CONTROL_FIELD_LIST = ['FMT', '001', '002', '003', '004', '005', '006', '007', '008', '009'];

    if (rec !== undefined) {
Severity: Major
Found in lib/MarcRecord.js - About 1 day to fix

    File MarcRecord.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    /*
    {
      leader: 'string',
      fields: [
    Severity: Minor
    Found in lib/MarcRecord.js - About 3 hrs to fix

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

          this.insertField = function(fieldDef, index) {
            
            if (isArray(fieldDef)) {
              if (fieldDef.length < 5) {
                throw new Error('Data field array must contain at least 5 elements: [tag, i1, i2, subcode1, subvalue1]');
      Severity: Minor
      Found in lib/MarcRecord.js - About 1 hr to fix

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

            this.containsFieldWithValue = function() {
              var args = Array.prototype.slice.call(arguments);
              if (args.length < 2) {
                throw new Error('At least 2 arguments are required');
              }
        Severity: Minor
        Found in lib/MarcRecord.js - About 1 hr to fix

          Function isEqual has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            Record.isEqual = function(record1, record2) {
              return record1.leader === record2.leader && fieldsEqual(record1.fields, record2.fields);
          
              function fieldsEqual(fields1, fields2) {
                
          Severity: Minor
          Found in lib/MarcRecord.js - About 1 hr to fix

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

                    var queryParams = args.slice(1).reduce(pairsReducer, [])
                      .filter(function(pair) {
                        return pair.length == 2;
                      })
                      .map(function(pair) {
            Severity: Major
            Found in lib/MarcRecord.js and 1 other location - About 2 hrs to fix
            lib/MarcRecord.js on lines 212..218

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

            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 expectedValues = args.slice(1).reduce(pairsReducer, [])
                      .filter(function(pair) {
                        return pair.length == 2;
                      })
                      .map(function(pair) {
            Severity: Major
            Found in lib/MarcRecord.js and 1 other location - About 2 hrs to fix
            lib/MarcRecord.js on lines 173..179

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

            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

                    return this.fields.filter(function(field) {
                      return field.tag === tag;
                    }).filter(function(field) {
                      return queryParams.every(function(expectedSubfield) {
                        return field.subfields.some(function(subfield) {
            Severity: Major
            Found in lib/MarcRecord.js and 1 other location - About 2 hrs to fix
            lib/MarcRecord.js on lines 225..231

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

            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

                    return fields.some(function(field) {
                      return subfieldQueryArray.every(function(expectedSubfield) {
                        return field.subfields.some(function(subfield) {
                          return subfield.code === expectedSubfield.code && subfield.value === expectedSubfield.value;
                        });
            Severity: Major
            Found in lib/MarcRecord.js and 1 other location - About 2 hrs to fix
            lib/MarcRecord.js on lines 181..189

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

            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

                this.getControlfields = function() {
                  return this.fields.filter(function(field) {
                    return CONTROL_FIELD_LIST.indexOf(field.tag) !== -1;
                  });
                };
            Severity: Major
            Found in lib/MarcRecord.js and 1 other location - About 1 hr to fix
            lib/MarcRecord.js on lines 157..161

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

            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

                this.getDatafields = function() {
                  return this.fields.filter(function(field) {
                    return CONTROL_FIELD_LIST.indexOf(field.tag) === -1;
                  });
                };
            Severity: Major
            Found in lib/MarcRecord.js and 1 other location - About 1 hr to fix
            lib/MarcRecord.js on lines 151..155

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

            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

            There are no issues that match your filters.

            Category
            Status