dsifford/academic-bloggers-toolkit

View on GitHub

Showing 1,811 of 1,811 total issues

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

        people: [
            {
                key: 'author',
                label: __('Author', 'academic-bloggers-toolkit'),
            },
Severity: Major
Found in src/js/utils/fieldmaps.ts and 2 other locations - About 1 hr to fix
src/js/utils/fieldmaps.ts on lines 369..386
src/js/utils/fieldmaps.ts on lines 460..477

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

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

export default function BibliographyEdit(props: Props) {
    const { attributes, setAttributes } = props;
    const { heading, headingAlign, headingLevel, isToggleable } = attributes;
    return (
        <>
Severity: Minor
Found in src/js/gutenberg/blocks/bibliography/edit.tsx - About 1 hr to fix

    Function transform has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    transform(node: HTMLDivElement) {
                        const heading = node.querySelector<HTMLElement>(
                            '.abt-bibliography__heading',
                        );
                        const body = node.querySelector<HTMLElement>(
    Severity: Minor
    Found in src/js/gutenberg/blocks/bibliography/index.ts - About 1 hr to fix

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

              items: {
                  type: 'array',
                  default: [],
                  source: 'query',
                  selector: 'li',
      Severity: Major
      Found in src/js/gutenberg/blocks/footnotes/index.ts and 1 other location - About 1 hr to fix
      src/js/gutenberg/blocks/bibliography/index.ts on lines 63..79

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

      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

              items: {
                  type: 'array',
                  default: [],
                  source: 'query',
                  selector: 'li',
      Severity: Major
      Found in src/js/gutenberg/blocks/bibliography/index.ts and 1 other location - About 1 hr to fix
      src/js/gutenberg/blocks/footnotes/index.ts on lines 22..38

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

      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 insertCitation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function insertCitation({
          onChange,
          parseCitations,
          selectedItems,
          value,
      Severity: Minor
      Found in src/js/gutenberg/formats/citation/citation.tsx - 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

                  <DialogToolbar>
                      <div className={styles.toolbar}>
                          <Button isLarge isPrimary type="submit">
                              {__('Confirm', 'academic-bloggers-toolkit')}
                          </Button>
      Severity: Major
      Found in src/js/gutenberg/dialogs/update-style/dialog.tsx and 1 other location - About 1 hr to fix
      src/js/gutenberg/dialogs/add-footnote/index.tsx on lines 44..50

      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

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

                  <DialogToolbar>
                      <div className={styles.toolbar}>
                          <Button isLarge isPrimary type="submit">
                              {__('Add footnote', 'academic-bloggers-toolkit')}
                          </Button>
      Severity: Major
      Found in src/js/gutenberg/dialogs/add-footnote/index.tsx and 1 other location - About 1 hr to fix
      src/js/gutenberg/dialogs/update-style/dialog.tsx on lines 32..38

      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

      Method register_script has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function register_script( string $relpath, array $extra_deps = [] ) {
          $handle        = 'abt-' . $relpath;
          $script_suffix = "/bundle/$relpath.js";
          $style_suffix  = "/bundle/$relpath.css";
      
      
      Severity: Minor
      Found in src/php/utils.php - About 1 hr to fix

        Method register_scripts has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function register_scripts() {
            //
            // Editor.
            //
            register_script( 'editor-stores' );
        Severity: Minor
        Found in src/academic-bloggers-toolkit.php - About 1 hr to fix

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

          async function addItem(
              id: string,
              references: CSL.Data[],
              items: Processor.BibItem[],
              setAttributes: (attrs: Partial<Attributes>) => void,
          Severity: Minor
          Found in src/js/gutenberg/blocks/static-bibliography/edit.tsx - About 1 hr to fix

            Function mergeLegacyCitations has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    mergeLegacyCitations() {
                        const selectedBlock = select(
                            'core/block-editor',
                        ).getSelectedBlock();
                        if (!selectedBlock) {
            Severity: Minor
            Found in src/js/gutenberg/formats/citation/citation.tsx - About 1 hr to fix

              Function fetchData has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function fetchData(
                  kind: IdentifierKind,
                  value: string,
              ): Promise<CSL.Data> {
                  let response: CSL.Data | ResponseError;
              Severity: Minor
              Found in src/js/gutenberg/components/reference-form-identifier/index.tsx - About 1 hr to fix

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

                                <PanelBody
                                    icon={<CountIcon count={uncitedItems.length} />}
                                    initialOpen={
                                        uncitedItems.length > 0 && citedItems.length === 0
                                    }
                Severity: Major
                Found in src/js/gutenberg/sidebar/sidebar.tsx and 1 other location - About 1 hr to fix
                src/js/gutenberg/sidebar/sidebar.tsx on lines 96..109

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

                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

                                <PanelBody
                                    icon={<CountIcon count={citedItems.length} />}
                                    initialOpen={citedItems.length > 0}
                                    opened={citedItems.length === 0 ? false : undefined}
                                    title={__('Cited Items', 'academic-bloggers-toolkit')}
                Severity: Major
                Found in src/js/gutenberg/sidebar/sidebar.tsx and 1 other location - About 1 hr to fix
                src/js/gutenberg/sidebar/sidebar.tsx on lines 110..125

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

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

                    get bibliography(): Processor.Bibliography {
                        let data: RawBib | false;
                        try {
                            data = this.engine.makeBibliography();
                            if (!data) {
                Severity: Minor
                Found in src/js/utils/processor.ts - About 1 hr to fix

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

                                  transform(node: HTMLDivElement) {
                                      const heading = node.querySelector<HTMLElement>(
                                          '.abt-bibliography__heading',
                                      );
                                      const body = node.querySelector<HTMLElement>(
                  Severity: Minor
                  Found in src/js/gutenberg/blocks/bibliography/index.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 stripListItem has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function stripListItem(item: Element | string): string {
                      if (typeof item === 'string') {
                          const container = document.createElement('div');
                          container.innerHTML = item;
                          const child = container.querySelector('.csl-entry');
                  Severity: Minor
                  Found in src/js/utils/editor.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 sidebar has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function sidebar(
                      state = SIDEBAR_INITIAL_STATE,
                      action: Action,
                  ): State['sidebar'] {
                      switch (action.type) {
                  Severity: Minor
                  Found in src/js/stores/ui/reducer.ts - About 1 hr to fix

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

                    export async function parseCSL(file: File): Promise<Style> {
                        const content = await readFile(file);
                        const xml = new DOMParser().parseFromString(content, 'application/xml');
                        const error = xml.querySelector('parsererror');
                        const label = xml.querySelector('info title');
                    Severity: Minor
                    Found in src/js/utils/file.ts - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language