digitalheir/bibtex-js

View on GitHub

Showing 66 of 66 total issues

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

function startsWithLowerCase(authorToken: BibStringDatum) {
    if (isString(authorToken)) {
        if (!authorToken) return false;
        const ch = authorToken.charAt(0);
        return ch.toLowerCase() === ch && ch.toUpperCase() !== ch;
Severity: Minor
Found in src/bibfile/bib-entry/bibliographic-entity/Author.ts - 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 findError has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const findError = (entry: BibEntry, field: MandatoryFields): (Error | undefined) => {
    const fields = entry.fields;
    if (isString(field)) {
        if (!fields[field])
            return new Error("Warning: expected " + entry.type + " with id " + entry._id

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

export function globContiguousStrings(data: BibStringData): (BibStringDatum | ContiguousSimpleString)[] {
    const result: (BibStringDatum | ContiguousSimpleString)[] = [];
    for (const element of data) {
        if (isString(element) || isNumber(element)) {
            if (result.length <= 0) {
Severity: Minor
Found in src/bibfile/datatype/string/bib-string-utils.ts - About 1 hr to fix

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

    export function isBibStringComponent(x: any): x is BibStringComponent {
        return typeof x.braceDepth === "number" && typeof x.type === "string";
    }
    Severity: Minor
    Found in src/bibfile/datatype/string/bib-string-utils.ts and 1 other location - About 50 mins to fix
    src/bibfile/datatype/string/BibStringComponent.ts on lines 29..31

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

    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

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

    function isBibStringComponent(x: any): x is BibStringComponent {
        return typeof x.braceDepth === "number" && typeof x.type === "string";
    }
    Severity: Minor
    Found in src/bibfile/datatype/string/BibStringComponent.ts and 1 other location - About 50 mins to fix
    src/bibfile/datatype/string/bib-string-utils.ts on lines 8..10

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

    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 3 locations. Consider refactoring.
    Open

                        for (let i = 0; i < match[1].length; i++) tokenz.push(match[1][i][3]);
    Severity: Major
    Found in src/parser/ts-parser.ts and 2 other locations - About 50 mins to fix
    src/parser/ts-parser.ts on lines 165..166
    src/parser/ts-parser.ts on lines 564..564

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

    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

    export function isWhitespace(token: any): token is WhitespaceToken {
        return typeof token.string === "string" && token.type === WS;
    }
    Severity: Minor
    Found in src/lexer/WhitespaceToken.ts and 1 other location - About 50 mins to fix
    src/bibfile/datatype/KeyVal.ts on lines 15..18

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

    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

    export function isKeyVal(data: any): data is KeyVal {
        return typeof data.key === "string"
            && data.value !== undefined;
    }
    Severity: Minor
    Found in src/bibfile/datatype/KeyVal.ts and 1 other location - About 50 mins to fix
    src/lexer/WhitespaceToken.ts on lines 13..15

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

    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 3 locations. Consider refactoring.
    Open

                for (let Ti = 0; Ti < data[0].length; Ti++) tokens.push(data[0][Ti][0]);
    Severity: Major
    Found in src/parser/ts-parser.ts and 2 other locations - About 50 mins to fix
    src/parser/ts-parser.ts on lines 165..166
    src/parser/ts-parser.ts on lines 417..417

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

    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

    export function isContiguousSimpleString(x: any): x is ContiguousSimpleString {
        return x.type === "ContiguousSimpleString" && isArray(x.data);
    }
    Severity: Minor
    Found in src/bibfile/datatype/string/bib-string-utils.ts and 1 other location - About 50 mins to fix
    src/bibfile/bib-entry/BibComment.ts on lines 35..37

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

    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

    export function isBibComment(n: any): n is BibComment {
        return n.type === "comment" && isArray(n.data);
    }
    Severity: Minor
    Found in src/bibfile/bib-entry/BibComment.ts and 1 other location - About 50 mins to fix
    src/bibfile/datatype/string/bib-string-utils.ts on lines 17..19

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

    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 3 locations. Consider refactoring.
    Open

                    for (let tk = 0; tk < data[0].length; tk++)
                        toeknz.push(data[0][tk][0]);
    Severity: Major
    Found in src/parser/ts-parser.ts and 2 other locations - About 50 mins to fix
    src/parser/ts-parser.ts on lines 417..417
    src/parser/ts-parser.ts on lines 564..564

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

    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

    Avoid deeply nested control flow statements.
    Open

                        if (stopAfter === undefined || stopAfter > 0)
                            match = pattern.exec(datum);
                        else
                            match = undefined;
    Severity: Major
    Found in src/bibfile/datatype/string/bib-string-utils.ts - About 45 mins to fix

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

      export function getOptionalFields(s: string): OptionalFields[] {
          if (hasOptionalFields(s)) {
              return optionalFields[s];
          } else {
              return [];
      src/bibfile/bib-entry/bibliographic-entity/mandatory-and-optional-fields.ts on lines 211..217

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

      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

      Avoid deeply nested control flow statements.
      Open

                          if (stopAfter === undefined || stopAfter > 0) {
                              splitted.push(buffer);
                              buffer = [];
                              if (stopAfter !== undefined && stopAfter > 0) stopAfter--;
                          }
      Severity: Major
      Found in src/bibfile/datatype/string/bib-string-utils.ts - About 45 mins to fix

        Function parseStringComponent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function parseStringComponent(braceDepth: number, obj: any): BibStringComponent | string | number | StringRef {
            if (isNumber(obj) || isString(obj))
                return /*new BibStringComponent(typeof obj, braceDepth, [*/obj/*])*/;
        
            if (isStringRef(obj))
        Severity: Minor
        Found in src/bibfile/datatype/string/bib-string-utils.ts - About 45 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

        Function joinTokens has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function joinTokens(arr) {
            const strs: any = [];
            for (let i = 0; i < arr.length; i++) {
                if (typeof arr[i] === "object") {
                    if (!arr[i].string) throw new Error("Expected token to have a string field called 'string' in object " + JSON.stringify(arr[i]));
        Severity: Minor
        Found in src/parser/ts-parser.ts - About 45 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

        Function firstVonLast has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function firstVonLast(outer: BibStringData): AuthorName {
            const authorTokens: BibStringData[] = splitOnPattern(outer, WHITESPACES);
        
            let vonStartInclusive = -1;
            let vonEndExclusive = -1;
        Severity: Minor
        Found in src/bibfile/bib-entry/bibliographic-entity/Author.ts - About 45 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

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

        export function getMandatoryFields(s: string): MandatoryFields[] {
            if (hasMandatoryFields(s)) {
                return mandatoryFields[s];
            } else {
                return [];
        src/bibfile/bib-entry/bibliographic-entity/mandatory-and-optional-fields.ts on lines 219..225

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

        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 9 locations. Consider refactoring.
        Open

                {
                    "name": "string_ref$subexpression$1$ebnf$1",
                    "symbols": ["string_ref$subexpression$1$ebnf$1", "stringreftoken"],
                    "postprocess": function arrpush(d) {
                        return d[0].concat([d[1]]);
        Severity: Major
        Found in src/parser/ts-parser.ts and 8 other locations - About 40 mins to fix
        src/parser/ts-parser.ts on lines 93..99
        src/parser/ts-parser.ts on lines 153..159
        src/parser/ts-parser.ts on lines 247..253
        src/parser/ts-parser.ts on lines 325..331
        src/parser/ts-parser.ts on lines 346..352
        src/parser/ts-parser.ts on lines 378..384
        src/parser/ts-parser.ts on lines 395..401
        src/parser/ts-parser.ts on lines 553..559

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

        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

        Severity
        Category
        Status
        Source
        Language