dsifford/academic-bloggers-toolkit

View on GitHub

Showing 1,811 of 1,811 total issues

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

    Function setFootnotes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function* setFootnotes() {
        const items = select('abt/data').getFootnotes();
        const blocksList = select('core/block-editor').getBlocks();
        const footnoteBlockIndex = blocksList.findIndex(
            ({ name }) => name === 'abt/footnotes',
    Severity: Minor
    Found in src/js/stores/data/actions.ts - About 1 hr to fix

      Function stripListItem has 28 lines of code (exceeds 25 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

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

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

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

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

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

          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

                  people: [
                      {
                          key: 'author',
                          label: __('Scriptwriter', 'academic-bloggers-toolkit'),
                      },
          Severity: Major
          Found in src/js/utils/fieldmaps.ts and 1 other location - About 1 hr to fix
          src/js/utils/fieldmaps.ts on lines 966..979

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

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

          function inject_author_meta() {
              global $post;
              if ( ! $post || ! is_singular() ) {
                  return;
              }
          Severity: Minor
          Found in src/php/frontend.php - About 1 hr to fix

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

            export function* removeReferences(itemIds: string[]) {
                const doc = getEditorDOM();
                const toDelete = [
                    ...doc.querySelectorAll<HTMLSpanElement>(CitationElement.selector),
                ].reduce(
            Severity: Minor
            Found in src/js/stores/data/actions.ts - About 1 hr to fix

              Method render_options_page has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function render_options_page() {
                  if ( ! current_user_can( 'manage_options' ) ) {
                      wp_die(
                          esc_html__(
                              'You do not have sufficient permissions to access this page.',
              Severity: Minor
              Found in src/php/options.php - About 1 hr to fix

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

                export default function AddReferenceDialog() {
                    const { addReference } = useDispatch('abt/data');
                    const [isOpen, setIsOpen] = useState(false);
                    const toggleDialog = () => setIsOpen(!isOpen);
                    return (
                Severity: Minor
                Found in src/js/gutenberg/dialogs/add-reference/index.tsx - About 1 hr to fix

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

                  function* updateEditorCitations(citations: Processor.CitationMeta[]) {
                      const doc = getEditorDOM();
                      for (const { html, id, sortedItems } of citations) {
                          const node = doc.querySelector<HTMLElement>(
                              createSelector(
                  Severity: Minor
                  Found in src/js/stores/data/actions.ts - About 1 hr to fix

                    Function iterate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function* iterate(
                        { formats = [] }: Value,
                        formatType?: string,
                    ): IterableIterator<Format> {
                        for (const fmts of formats) {
                    Severity: Minor
                    Found in src/js/utils/formats.ts - About 55 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

                    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 23 and the first side effect is on line 21.
                    Open

                    <?php

                    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12.
                    Open

                    <?php
                    Severity: Minor
                    Found in src/php/editor.php by phpcodesniffer

                    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12.
                    Open

                    <?php
                    Severity: Minor
                    Found in src/php/endpoints.php by phpcodesniffer

                    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12.
                    Open

                    <?php
                    Severity: Minor
                    Found in src/php/options.php by phpcodesniffer

                    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 21 and the first side effect is on line 12.
                    Open

                    <?php
                    Severity: Minor
                    Found in src/php/frontend.php by phpcodesniffer

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

                    function init_editor_state( int $post_id ) {
                        $meta = get_post_meta( $post_id );
                    
                        if ( ! array_key_exists( '_abt_state', $meta ) || ! has_blocks( $post_id ) ) {
                            $state = (object) [
                    Severity: Minor
                    Found in src/php/editor.php - 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 parseCSL has a Cognitive Complexity of 8 (exceeds 5 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 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

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

                                if (node.firstElementChild) {
                                    node.dataset.hasChildren = 'true';
                                    node.firstElementChild.innerHTML =
                                        ZERO_WIDTH_SPACE +
                                        node.firstElementChild.innerHTML +
                    Severity: Minor
                    Found in src/js/stores/data/actions.ts and 1 other location - About 45 mins to fix
                    src/js/gutenberg/formats/citation/citation.tsx on lines 121..130

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language