wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method maybeDoRedirect has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function maybeDoRedirect(
        File $img,
        array $params,
        bool $isTemp,
        bool $isOld,
Severity: Minor
Found in includes/filerepo/ThumbnailEntryPoint.php - About 1 hr to fix

    Method run has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run(): Response {
            $this->contentHelper->checkAccessPermission();
            $page = $this->contentHelper->getPageIdentity();
            $params = $this->getRequest()->getQueryParams();
    
    
    Severity: Minor
    Found in includes/Rest/Handler/PageHTMLHandler.php - About 1 hr to fix

      Method run has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function run(): Response {
              $this->contentHelper->checkAccess();
              $page = $this->contentHelper->getPageIdentity();
      
              if ( !$page->exists() ) {
      Severity: Minor
      Found in includes/Rest/Handler/PageSourceHandler.php - About 1 hr to fix

        Method acceptable has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function acceptable( array &$attribs ): bool {
                $request = $this->getRequest();
                $format = $attribs['opts']['format'];
        
                if ( $format === ParsoidFormatHelper::FORMAT_WIKITEXT ) {
        Severity: Minor
        Found in includes/Rest/Handler/ParsoidHandler.php - About 1 hr to fix

          Method fillParserOutput has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function fillParserOutput(
                  Content $content,
                  ContentParseParams $cpoParams,
                  ParserOutput &$parserOutput
              ) {
          Severity: Minor
          Found in includes/content/WikitextContentHandler.php - About 1 hr to fix

            Method defaultSearchBackend has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function defaultSearchBackend( $namespaces, $search, $limit, $offset ) {
                    if ( !$namespaces ) {
                        $namespaces = [ NS_MAIN ];
                    }
            
            
            Severity: Minor
            Found in includes/search/PrefixSearch.php - About 1 hr to fix

              Method dump has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function dump( $history, $text = WikiExporter::TEXT ) {
                      # Notice messages will foul up your XML output even if they're
                      # relatively harmless.
                      if ( ini_get( 'display_errors' ) ) {
                          ini_set( 'display_errors', 'stderr' );
              Severity: Minor
              Found in maintenance/includes/BackupDumper.php - About 1 hr to fix

                Method restoreText has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function restoreText( $revIds, $xml ) {
                        global $wgDBname;
                        $tmpDir = wfTempDir();
                
                        if ( !count( $revIds ) ) {
                Severity: Minor
                Found in maintenance/storage/checkStorage.php - About 1 hr to fix

                  Method startElement has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function startElement( $parser, $name, $attribs ) {
                          $this->checkpointJustWritten = false;
                  
                          $this->clearOpenElement( null );
                          $this->lastName = $name;
                  Severity: Minor
                  Found in maintenance/includes/TextPassDumper.php - About 1 hr to fix

                    Method execute has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function execute() {
                            $this->init();
                    
                            $showWiki = $this->getOption( 'show-wiki' );
                            $wikiId = WikiMap::getCurrentWikiId();
                    Severity: Minor
                    Found in maintenance/grep.php - About 1 hr to fix

                      Method execute has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function execute() {
                              // Settings we will display
                              $res = [];
                      
                              # Default: dump any wg / wmg variable
                      Severity: Minor
                      Found in maintenance/getConfiguration.php - About 1 hr to fix

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

                                            [
                                                'name' => 'hideanons',
                                                // rcshowhideanons-show, rcshowhideanons-hide,
                                                // wlshowhideanons
                                                'showHideSuffix' => 'showhideanons',
                        Severity: Major
                        Found in includes/specialpage/ChangesListSpecialPage.php and 1 other location - About 1 hr to fix
                        includes/specialpage/ChangesListSpecialPage.php on lines 134..148

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

                        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

                        <?php
                        /**
                         * This program is free software; you can redistribute it and/or modify
                         * it under the terms of the GNU General Public License as published by
                         * the Free Software Foundation; either version 2 of the License, or
                        Severity: Major
                        Found in includes/languages/LanguageBs.php and 2 other locations - About 1 hr to fix
                        includes/languages/LanguageHsb.php on lines 1..51
                        includes/languages/LanguageSl.php on lines 1..57

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

                        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

                            public function __construct(
                                ServiceOptions $options,
                                RevisionLookup $revisionLookup,
                                TitleFormatter $titleFormatter,
                                PageLookup $pageLookup,
                        Severity: Major
                        Found in includes/Rest/Handler/Helper/PageContentHelper.php and 1 other location - About 1 hr to fix
                        includes/cache/LinkBatchFactory.php on lines 71..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 116.

                        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

                        <?php
                        /**
                         * This program is free software; you can redistribute it and/or modify
                         * it under the terms of the GNU General Public License as published by
                         * the Free Software Foundation; either version 2 of the License, or
                        Severity: Major
                        Found in includes/languages/LanguageSl.php and 2 other locations - About 1 hr to fix
                        includes/languages/LanguageBs.php on lines 1..54
                        includes/languages/LanguageHsb.php on lines 1..51

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

                        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

                        <?php
                        /**
                         * This program is free software; you can redistribute it and/or modify
                         * it under the terms of the GNU General Public License as published by
                         * the Free Software Foundation; either version 2 of the License, or
                        Severity: Major
                        Found in includes/languages/LanguageHsb.php and 2 other locations - About 1 hr to fix
                        includes/languages/LanguageBs.php on lines 1..54
                        includes/languages/LanguageSl.php on lines 1..57

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

                        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

                            public function __construct(
                                LinkCache $linkCache,
                                TitleFormatter $titleFormatter,
                                Language $contentLanguage,
                                GenderCache $genderCache,
                        Severity: Major
                        Found in includes/cache/LinkBatchFactory.php and 1 other location - About 1 hr to fix
                        includes/Rest/Handler/Helper/PageContentHelper.php on lines 80..96

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

                        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

                                            [
                                                'name' => 'hideliu',
                                                // rcshowhideliu-show, rcshowhideliu-hide,
                                                // wlshowhideliu
                                                'showHideSuffix' => 'showhideliu',
                        Severity: Major
                        Found in includes/specialpage/ChangesListSpecialPage.php and 1 other location - About 1 hr to fix
                        includes/specialpage/ChangesListSpecialPage.php on lines 149..162

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

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

                            extlink: function ( nodes ) {
                                let $el,
                                    arg = nodes[ 0 ],
                                    contents = nodes[ 1 ];
                                if ( arg instanceof $ && !arg.hasClass( 'mediaWiki_htmlEmitter' ) ) {
                        Severity: Minor
                        Found in resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js - 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 sanitizeIP has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            sanitizeIP: function ( ip ) {
                                if ( typeof ip !== 'string' ) {
                                    return null;
                                }
                                ip = ip.trim();
                        Severity: Minor
                        Found in resources/src/mediawiki.util/util.js - 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

                        Severity
                        Category
                        Status
                        Source
                        Language