digitalheir/bibtex-js

View on GitHub

Showing 66 of 66 total issues

File ts-parser.ts has 587 lines of code (exceeds 250 allowed). Consider refactoring.
Open

function id(x) {
    return x[0];
}

const isNumber = function (x) {
Severity: Major
Found in src/parser/ts-parser.ts - About 1 day to fix

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

            {
                "name": "stringreftoken",
                "symbols": ["stringreftoken$subexpression$1"],
                "postprocess": function (data) {
                    if (typeof data[0][0] === "object") {
    Severity: Major
    Found in src/parser/ts-parser.ts and 1 other location - About 6 hrs to fix
    src/parser/ts-parser.ts on lines 490..503

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

    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

            {
                "name": "stringreftoken_n_num",
                "symbols": ["stringreftoken_n_num$subexpression$1"],
                "postprocess": function (data) {
                    if (typeof data[0][0] === "object") {
    Severity: Major
    Found in src/parser/ts-parser.ts and 1 other location - About 6 hrs to fix
    src/parser/ts-parser.ts on lines 468..481

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

    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

    Function splitOnPattern has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    export function splitOnPattern(data: BibStringData, pattern: RegExp, stopAfter?: number): BibStringData[] {
        const splitted: BibStringData[] = [];
    
        let buffer: BibStringData = [];
        for (const datum of data) {
    Severity: Minor
    Found in src/bibfile/datatype/string/bib-string-utils.ts - About 5 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

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

            {
                "name": "quoted_string",
                "symbols": [quote_dbl, "quoted_string$ebnf$1", quote_dbl],
                "postprocess": function (data) {
                    const tks: any = [];
    Severity: Major
    Found in src/parser/ts-parser.ts and 1 other location - About 2 hrs to fix
    src/parser/ts-parser.ts on lines 332..341

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

    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

            {
                "name": "braced_string",
                "symbols": [brace_l, "braced_string$ebnf$1", brace_r],
                "postprocess": function (data) {
                    const tkz: any = [];
    Severity: Major
    Found in src/parser/ts-parser.ts and 1 other location - About 2 hrs to fix
    src/parser/ts-parser.ts on lines 353..361

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

    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

    Function flattenMyArray has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    export const flattenMyArray = function (arr: any[], result?: any[]): any[] {
        if (!result) result = [];
        for (let i = 0, length = arr.length; i < length; i++) {
            const value: any = arr[i];
            if (Array.isArray(value)) {
    Severity: Minor
    Found in src/util.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

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

        for (let i = 0; i < vonLast.length - 1; i++)
            if (startsWithLowerCaseBSD(vonLast[i])) {
                if (vonStartInclusive < 0) vonStartInclusive = i;
                vonEndExclusive = i + 1;
            }
    Severity: Major
    Found in src/bibfile/bib-entry/bibliographic-entity/Author.ts and 1 other location - About 1 hr to fix
    src/bibfile/bib-entry/bibliographic-entity/Author.ts on lines 173..177

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

    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

        for (let i = 0; i < vonLast.length - 1; i++)
            if (startsWithLowerCaseBSD(vonLast[i])) {
                if (vonStartInclusive < 0) vonStartInclusive = i;
                vonEndExclusive = i + 1;
            }
    Severity: Major
    Found in src/bibfile/bib-entry/bibliographic-entity/Author.ts and 1 other location - About 1 hr to fix
    src/bibfile/bib-entry/bibliographic-entity/Author.ts on lines 138..142

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

    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

    Function globContiguousStrings has a Cognitive Complexity of 13 (exceeds 5 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

    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 copyWithResolvedStringReferences(obj: BibStringComponent,
                                                     seenBeforeStack: { [key: string]: boolean },
                                                     alreadyResolved: { [key: string]: /*Resolved*/FieldValue },
                                                     refs: { [key: string]: FieldValue }): OuterQuotedString | OuterBracedString {
        const newData = resolveStringReferences(obj, seenBeforeStack, alreadyResolved, refs);
    Severity: Major
    Found in src/bibfile/bib-entry/BibStringEntry.ts and 1 other location - About 1 hr to fix
    src/bibfile/bib-entry/BibStringEntry.ts on lines 63..72

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

    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 resolveStringReferences(o: BibStringComponent, seenBeforeStack: { [key: string]: boolean },
                                            alreadyResolved: { [key: string]: /*Resolved*/FieldValue },
                                            refs: { [key: string]: FieldValue }): BibStringData {
        return o.data.map(datum => {
            if (isString(datum) || isNumber(datum)) return datum;
    Severity: Major
    Found in src/bibfile/bib-entry/BibStringEntry.ts and 1 other location - About 1 hr to fix
    src/bibfile/bib-entry/BibStringEntry.ts on lines 116..133

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

    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

    Function flattenQuotedString has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function flattenQuotedString(data: BibStringDatum, hideQuotes?: boolean): BibStringDatum | BibStringData {
        if (isBracedString(data))
            return data;
        if (isQuotedString(data)) {
            const flattenedQuotedString: BibStringData = flattenQuotedStrings(data.data, true);
    Severity: Minor
    Found in src/bibfile/datatype/string/bib-string-utils.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

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

    export const specialChars = {
        "@": true,
        "(": true,
        ")": true,
        "{": true,
    Severity: Major
    Found in src/lexer/Token.ts and 1 other location - About 1 hr to fix
    src/lexer/NumericToken.ts on lines 16..27

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

    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 const numericChars = {
        "0": true,
        "1": true,
        "2": true,
        "3": true,
    Severity: Major
    Found in src/lexer/NumericToken.ts and 1 other location - About 1 hr to fix
    src/lexer/Token.ts on lines 16..27

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

    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

    Function splitOnPattern has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function splitOnPattern(data: BibStringData, pattern: RegExp, stopAfter?: number): BibStringData[] {
        const splitted: BibStringData[] = [];
    
        let buffer: BibStringData = [];
        for (const datum of data) {
    Severity: Minor
    Found in src/bibfile/datatype/string/bib-string-utils.ts - About 1 hr to fix

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

      const flattenO = (wrapper: any): string => isString(wrapper) ? wrapper
          : typeof wrapper === "number" ? wrapper.toString()
              // : (isString(wrapper.type) && wrapper.type === "@bib" && isString(wrapper.string)) ? "@" + wrapper.string
              : wrapper["type"] === "@bib" ? "@" + mustBeString(wrapper.string)
                  : wrapper["type"] === "escapedEntry" ? "\\" + flattenO(wrapper.data)
      Severity: Minor
      Found in src/bibfile/bib-entry/BibComment.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 constructor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          constructor(content: (NonBibComment | BibComment)[]) {
              this.content = content;
              this.comments = content.filter(isBibComment).map(c => {
                  if (isBibComment(c))return c; else throw new Error();
              });
      Severity: Minor
      Found in src/bibfile/BibFile.ts - About 1 hr to fix

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

                this.preambles_raw = content.filter(c => isPreamble(c)).map(c => {
                    if (isPreamble(c)) return c; else throw new Error();
                });
        Severity: Major
        Found in src/bibfile/BibFile.ts and 1 other location - About 1 hr to fix
        src/bibfile/BibFile.ts on lines 77..80

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

        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.entries_raw = content.filter(c => isBibEntry(c)).map(c => {
                    if (isBibEntry(c)) return c;
                    else throw new Error();
                });
        Severity: Major
        Found in src/bibfile/BibFile.ts and 1 other location - About 1 hr to fix
        src/bibfile/BibFile.ts on lines 59..61

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

        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