dsifford/academic-bloggers-toolkit

View on GitHub

Showing 43 of 1,811 total issues

File fieldmaps.ts has 1134 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { HTMLProps } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

interface BaseField<T = string> {
    readonly key: T;
Severity: Major
Found in src/js/utils/fieldmaps.ts - About 2 days to fix

    Function get_website_meta has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    function get_website_meta() {
        if ( ! extension_loaded( 'dom' ) || ! extension_loaded( 'libxml' ) ) {
            wp_send_json_error( [], 501 );
            exit;
        }
    Severity: Minor
    Found in src/php/endpoints.php - About 6 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

    Function ReferenceFormManual has 129 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function ReferenceFormManual(props: Props) {
        const [errorMessage, setErrorMessage] = useState('');
        const [data, setData] = useState<CSL.Data>({
            id: '',
            type: 'webpage',
    Severity: Major
    Found in src/js/gutenberg/components/reference-form-manual/index.tsx - About 5 hrs to fix

      Function ToolbarMenu has 129 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function ToolbarMenu() {
          const { parseCitations, parseFootnotes, removeAllCitations } = useDispatch(
              'abt/data',
          );
          const { setSidebarSortMode, setSidebarSortOrder } = useDispatch('abt/ui');
      Severity: Major
      Found in src/js/gutenberg/sidebar/toolbar-menu.tsx - About 5 hrs to fix

        Function Sidebar has 125 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function Sidebar() {
            const { parseCitations, parseFootnotes, updateReference } = useDispatch(
                'abt/data',
            );
            const { toggleItemSelected } = useDispatch('abt/ui');
        Severity: Major
        Found in src/js/gutenberg/sidebar/sidebar.tsx - About 5 hrs to fix

          Method get_website_meta has 119 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function get_website_meta() {
              if ( ! extension_loaded( 'dom' ) || ! extension_loaded( 'libxml' ) ) {
                  wp_send_json_error( [], 501 );
                  exit;
              }
          Severity: Major
          Found in src/php/endpoints.php - About 4 hrs to fix

            Function StyleSearch has 104 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function StyleSearch(props: Props) {
                const [inputValue, setInputValue] = useState(props.value.label);
                const [suggestions, setSuggestions] = useState<Style[]>([]);
                const [isLoading, setIsLoading] = useState(false);
            
            
            Severity: Major
            Found in src/js/components/style-search/index.tsx - About 4 hrs to fix

              Function StyleForm has 87 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function StyleForm() {
                  const [style, setStyle] = useState(SAVED_STYLE);
                  const [errorMessage, setErrorMessage] = useState('');
              
                  return (
              Severity: Major
              Found in src/js/options-page/style-form.tsx - About 3 hrs to fix

                Function StaticBibEdit has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function StaticBibEdit(props: Props) {
                    const {
                        attributes: { orderedList, items },
                        setAttributes,
                    } = props;
                Severity: Major
                Found in src/js/gutenberg/blocks/static-bibliography/edit.tsx - About 2 hrs to fix

                  Function IdentifierForm has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function IdentifierForm(props: Props) {
                      const { setIdentifierKind } = useDispatch('abt/ui');
                      const kind = useSelect(select => select('abt/ui').getIdentifierKind());
                  
                      const [value, setValue] = useState('');
                  Severity: Major
                  Found in src/js/gutenberg/components/reference-form-identifier/index.tsx - About 2 hrs to fix

                    File webpack.config.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /* eslint-disable @typescript-eslint/no-var-requires */
                    import { promises as fs } from 'fs';
                    import path from 'path';
                    import { promisify } from 'util';
                    
                    
                    Severity: Minor
                    Found in webpack.config.ts - About 2 hrs to fix

                      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

                          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

                          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

                                    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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language