dsifford/academic-bloggers-toolkit

View on GitHub

Showing 1,811 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

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

                          <section
                              aria-label={__('Footnotes', 'academic-bloggers-toolkit')}
                              className="abt-footnotes"
                              role="region"
                          >
                  Severity: Major
                  Found in src/js/gutenberg/blocks/footnotes/save.tsx and 1 other location - About 2 hrs to fix
                  src/js/gutenberg/blocks/footnotes/edit.tsx on lines 11..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 91.

                  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

                          <section
                              aria-label={__('Footnotes', 'academic-bloggers-toolkit')}
                              className="abt-footnotes"
                          >
                              <hr />
                  Severity: Major
                  Found in src/js/gutenberg/blocks/footnotes/edit.tsx and 1 other location - About 2 hrs to fix
                  src/js/gutenberg/blocks/footnotes/save.tsx on lines 12..29

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

                  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

                      return (
                          <ol className="abt-bibliography__body" {...containerAttrs}>
                              {atts.items.map(({ content, id }) => (
                                  <RichText.Content
                                      key={id}
                  Severity: Major
                  Found in src/js/gutenberg/blocks/bibliography/save.tsx and 1 other location - About 2 hrs to fix
                  src/js/gutenberg/blocks/bibliography/edit.tsx on lines 143..154

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

                  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

                      return (
                          <ol className="abt-bibliography__body" {...containerAttrs}>
                              {atts.items.map(({ content, id }) => (
                                  <RichText.Content
                                      key={id}
                  Severity: Major
                  Found in src/js/gutenberg/blocks/bibliography/edit.tsx and 1 other location - About 2 hrs to fix
                  src/js/gutenberg/blocks/bibliography/save.tsx on lines 58..69

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

                  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 3 locations. Consider refactoring.
                  Open

                                          <input
                                              required
                                              autoComplete="off"
                                              data-lpignore="true"
                                              placeholder={__(
                  Severity: Major
                  Found in src/js/gutenberg/components/people-fields/index.tsx and 2 other locations - About 2 hrs to fix
                  src/js/gutenberg/components/people-fields/index.tsx on lines 91..107
                  src/js/gutenberg/components/people-fields/index.tsx on lines 108..124

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

                  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 3 locations. Consider refactoring.
                  Open

                                              <input
                                                  required
                                                  autoComplete="off"
                                                  data-lpignore="true"
                                                  placeholder={__(
                  Severity: Major
                  Found in src/js/gutenberg/components/people-fields/index.tsx and 2 other locations - About 2 hrs to fix
                  src/js/gutenberg/components/people-fields/index.tsx on lines 108..124
                  src/js/gutenberg/components/people-fields/index.tsx on lines 128..144

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

                  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 3 locations. Consider refactoring.
                  Open

                                              <input
                                                  required
                                                  autoComplete="off"
                                                  data-lpignore="true"
                                                  placeholder={__(
                  Severity: Major
                  Found in src/js/gutenberg/components/people-fields/index.tsx and 2 other locations - About 2 hrs to fix
                  src/js/gutenberg/components/people-fields/index.tsx on lines 91..107
                  src/js/gutenberg/components/people-fields/index.tsx on lines 128..144

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

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

                      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

                      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 145..162
                      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

                      Severity
                      Category
                      Status
                      Source
                      Language