wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

      createVNode(_component_cdx_menu, mergeProps({
        id: _ctx.menuId,
        ref: "menu",
        selected: _ctx.modelWrapper,
        "onUpdate:selected": _cache[2] || (_cache[2] = ($event) => _ctx.modelWrapper = $event),
Severity: Major
Found in resources/lib/codex/codex.js and 1 other location - About 1 day to fix
resources/lib/codex/codex.js on lines 5129..5148

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

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

  setup(props, { attrs, emit, slots }) {
    const form = ref();
    const menu = ref();
    const menuId = useGeneratedId("typeahead-search-menu");
    const expanded = ref(false);
Severity: Minor
Found in resources/lib/codex/codex.js - About 1 day 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 finalizeHeadings has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    private function finalizeHeadings( $text, $origText, $isMain = true ) {
        # Inhibit editsection links if requested in the page
        if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
            $maybeShowEditLink = false;
        } else {
Severity: Minor
Found in includes/parser/Parser.php - About 1 day 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

WebRequest has 67 functions (exceeds 20 allowed). Consider refactoring.
Open

class WebRequest {
    /**
     * The parameters from $_GET, $_POST and the path router
     * @var array
     */
Severity: Major
Found in includes/Request/WebRequest.php - About 1 day to fix

    Installer has 67 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class Installer {
    
        /**
         * URL to mediawiki-announce list summary page
         */
    Severity: Major
    Found in includes/installer/Installer.php - About 1 day to fix

      File ApiHelp.php has 575 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Copyright © 2014 Wikimedia Foundation and contributors
       *
       * This program is free software; you can redistribute it and/or modify
      Severity: Major
      Found in includes/api/ApiHelp.php - About 1 day to fix

        Function performRequest has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function performRequest() {
                global $wgTitle;
        
                $context = $this->getContext();
        
        
        Severity: Minor
        Found in includes/actions/ActionEntryPoint.php - About 1 day 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 run has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function run( ApiPageSet $resultPageSet = null ) {
                $db = $this->getDB();
                $params = $this->extractRequestParams( false );
        
                $result = $this->getResult();
        Severity: Minor
        Found in includes/api/ApiQueryAllRevisions.php - About 1 day 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 getFinalParamDescription has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getFinalParamDescription() {
                $prefix = $this->getModulePrefix();
                $name = $this->getModuleName();
                $path = $this->getModulePath();
        
        
        Severity: Minor
        Found in includes/api/ApiBase.php - About 1 day 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

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

                return {
                    top: (
                        pageY                                                                // The absolute mouse position
                        - this.offset.click.top                                                    // Click offset (relative to the element)
                        - this.offset.relative.top                                                // Only for relative positioned nodes: Relative offset from element to offset parent
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.sortable.js and 1 other location - About 1 day to fix
        resources/lib/jquery.ui/jquery.ui.draggable.js on lines 461..476

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

        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 {
                    top: (
                        pageY                                                                // The absolute mouse position
                        - this.offset.click.top                                                    // Click offset (relative to the element)
                        - this.offset.relative.top                                                // Only for relative positioned nodes: Relative offset from element to offset parent
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 1 day to fix
        resources/lib/jquery.ui/jquery.ui.sortable.js on lines 960..975

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

        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

        File DateTimeInputWidget.js has 572 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        ( function () {
        
            /**
             * @classdesc DateTimeInputWidgets can be used to input a date, a time, or
             * a date and time, in either UTC or the user's local timezone.
        Severity: Major
        Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 day to fix

          File WatchedItemQueryService.php has 571 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace MediaWiki\Watchlist;
          
          use ApiUsageException;
          Severity: Major
          Found in includes/watchlist/WatchedItemQueryService.php - About 1 day to fix

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

            $namespaceAliases = [
                # Aliases to kk-latn namespaces
                'Taspa'               => NS_MEDIA,
                'Arnaýı'              => NS_SPECIAL,
                'Talqılaw'            => NS_TALK,
            Severity: Major
            Found in languages/messages/MessagesKk_cyrl.php and 1 other location - About 1 day to fix
            languages/messages/MessagesKk_latn.php on lines 41..81

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

            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

            $namespaceAliases = [
                # Aliases to kk-cyrl namespaces
                'Таспа'               => NS_MEDIA,
                'Арнайы'              => NS_SPECIAL,
                'Талқылау'            => NS_TALK,
            Severity: Major
            Found in languages/messages/MessagesKk_latn.php and 1 other location - About 1 day to fix
            languages/messages/MessagesKk_cyrl.php on lines 50..90

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

            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

            TransactionManager has 66 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class TransactionManager {
                /** Transaction is in a error state requiring a full or savepoint rollback */
                public const STATUS_TRX_ERROR = 1;
                /** Transaction is active and in a normal state */
                public const STATUS_TRX_OK = 2;
            Severity: Major
            Found in includes/libs/rdbms/database/TransactionManager.php - About 1 day to fix

              File DeletePage.php has 569 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace MediaWiki\Page;
              
              use BadMethodCallException;
              Severity: Major
              Found in includes/page/DeletePage.php - About 1 day to fix

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

                        do {
                          if (s.pending === s.pending_buf_size) {
                            //--- HCRC_UPDATE(beg) ---//
                            if (s.gzhead.hcrc && s.pending > beg) {
                              strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
                Severity: Major
                Found in resources/lib/pako/pako_deflate.js and 1 other location - About 1 day to fix
                resources/lib/pako/pako_deflate.js on lines 3194..3215

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

                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

                        do {
                          if (s.pending === s.pending_buf_size) {
                            //--- HCRC_UPDATE(beg) ---//
                            if (s.gzhead.hcrc && s.pending > beg) {
                              strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
                Severity: Major
                Found in resources/lib/pako/pako_deflate.js and 1 other location - About 1 day to fix
                resources/lib/pako/pako_deflate.js on lines 3159..3180

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

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

                    public function continueAuthentication( array $reqs ) {
                        $session = $this->request->getSession();
                        try {
                            if ( !$session->canSetUser() ) {
                                // Caller should have called canAuthenticateNow()
                Severity: Minor
                Found in includes/auth/AuthManager.php - About 1 day 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