dsifford/academic-bloggers-toolkit

View on GitHub

Showing 1,811 of 1,811 total issues

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/gutenberg/formats/citation/citation.tsx and 1 other location - About 45 mins to fix
src/js/stores/data/actions.ts on lines 210..219

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

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

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

                            {
                                icon: 'editor-ul',
                                title: __(
                                    'Convert to unordered list',
                                    'academic-bloggers-toolkit',
    Severity: Minor
    Found in src/js/gutenberg/blocks/static-bibliography/edit.tsx and 1 other location - About 35 mins to fix
    src/js/gutenberg/blocks/static-bibliography/edit.tsx on lines 77..87

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

    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

                            {
                                icon: 'editor-ol',
                                title: __(
                                    'Convert to ordered list',
                                    'academic-bloggers-toolkit',
    Severity: Minor
    Found in src/js/gutenberg/blocks/static-bibliography/edit.tsx and 1 other location - About 35 mins to fix
    src/js/gutenberg/blocks/static-bibliography/edit.tsx on lines 66..76

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

    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

    Expected 0 spaces between opening bracket and type hint "array"; 1 found
    Open

    function add_options_link( array $links ): array {

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

    function ReferenceFormManual(props: Props) {
        const [errorMessage, setErrorMessage] = useState('');
        const [data, setData] = useState<CSL.Data>({
            id: '',
            type: 'webpage',
    Severity: Minor
    Found in src/js/gutenberg/components/reference-form-manual/index.tsx - 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

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( version_compare( ABT_VERSION, $options['VERSION'] ?? '0', '>' ) ) {

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

    export default function StyleForm() {
        const [style, setStyle] = useState(SAVED_STYLE);
        const [errorMessage, setErrorMessage] = useState('');
    
        return (
    Severity: Minor
    Found in src/js/options-page/style-form.tsx - 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

    Expected 0 spaces between opening bracket and type hint "array"; 1 found
    Open

    function add_donate_link( array $links, string $file ): array {

    Expected 0 spaces between argument "$links" and closing bracket; 1 found
    Open

    function add_options_link( array $links ): array {

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

    Expected 0 spaces between argument "$file" and closing bracket; 1 found
    Open

    function add_donate_link( array $links, string $file ): array {

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( plugin_basename( __FILE__ ) === $file ) {

    Expected 0 spaces before closing bracket; 1 found
    Open

    if ( is_admin() ) {

    Expected 0 spaces before closing bracket; 1 found
    Open

                foreach ( $legacy_meta->CSL as $id => $data ) { // phpcs:ignore
    Severity: Minor
    Found in src/php/editor.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( ! array_key_exists( '_abt_state', $meta ) || ! has_blocks( $post_id ) ) {
    Severity: Minor
    Found in src/php/editor.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            if ( array_key_exists( '_abt-reflist-state', $meta ) ) {
    Severity: Minor
    Found in src/php/editor.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( $issued ) {
    Severity: Minor
    Found in src/php/endpoints.php by phpcodesniffer
    Severity
    Category
    Status
    Source
    Language