dsifford/academic-bloggers-toolkit

View on GitHub

Showing 43 of 1,811 total issues

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

    export function getSortedItems(
        state: State,
        mode: 'date' | 'publication' | 'title' = 'title',
        order: 'asc' | 'desc' = 'asc',
        kind?: 'cited' | 'uncited',
    Severity: Minor
    Found in src/js/stores/data/selectors.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

        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

              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

                        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

                        Function neighbors has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            dir: 'left' | 'right',
                            idx: number,
                            val: Value,
                            type: string,
                            located: Format[] = [],
                        Severity: Minor
                        Found in src/js/utils/formats.ts - About 35 mins to fix

                          Function inject_author_meta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function inject_author_meta() {
                              global $post;
                              if ( ! $post || ! is_singular() ) {
                                  return;
                              }
                          Severity: Minor
                          Found in src/php/frontend.php - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          async function parseCSL(
                              filepath: string,
                              isIndependent: boolean,
                          ): Promise<Style[]> {
                              const xml = await readfile(filepath, { encoding: 'utf-8' });
                          Severity: Minor
                          Found in scripts/update-styles.ts - About 35 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 updateEditorCitations has a Cognitive Complexity of 7 (exceeds 5 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 35 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

                          Severity
                          Category
                          Status
                          Source
                          Language