wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

File jquery.ui.autocomplete.js has 463 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * jQuery UI Autocomplete 1.9.2
 * http://jqueryui.com
 *
 * Copyright 2012 jQuery Foundation and other contributors
Severity: Minor
Found in resources/lib/jquery.ui/jquery.ui.autocomplete.js - About 7 hrs to fix

    File mustache.js has 462 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    (function (global, factory) {
      typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
      typeof define === 'function' && define.amd ? define(factory) :
      (global = global || self, global.Mustache = factory());
    }(this, (function () { 'use strict';
    Severity: Minor
    Found in resources/lib/mustache/mustache.js - About 7 hrs to fix

      File BlockLevelPass.php has 462 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      /**
       * This is the part of the wikitext parser which handles automatic paragraphs
       * and conversion of start-of-line prefixes to HTML lists.
      Severity: Minor
      Found in includes/parser/BlockLevelPass.php - About 7 hrs to fix

        Function conditionParse has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

        function conditionParse( $root, spec ) {
            let v, fields, func;
        
            const op = spec[ 0 ];
            let l = spec.length;
        Severity: Minor
        Found in resources/src/mediawiki.htmlform/cond-state.js - About 7 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 run has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

            private function run( $resultPageSet = null ) {
                $params = $this->extractRequestParams();
        
                // Extract parameters
                $query = $params['search'];
        Severity: Minor
        Found in includes/api/ApiQuerySearch.php - About 7 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 processDbResults has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

            private function processDbResults( $res, $page, $params ) {
                $revisions = [];
        
                if ( $res ) {
                    $sizes = [];
        Severity: Minor
        Found in includes/Rest/Handler/PageHistoryHandler.php - About 7 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

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

                if (nodeName == 'input') {
                    target.disabled = false;
                    inst.trigger.filter('button').
                        each(function() { this.disabled = false; }).end().
                        filter('img').css({opacity: '1.0', cursor: ''});
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.datepicker.js and 1 other location - About 7 hrs to fix
        resources/lib/jquery.ui/jquery.ui.datepicker.js on lines 401..412

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

        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

                if (nodeName == 'input') {
                    target.disabled = true;
                    inst.trigger.filter('button').
                        each(function() { this.disabled = true; }).end().
                        filter('img').css({opacity: '0.5', cursor: 'default'});
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.datepicker.js and 1 other location - About 7 hrs to fix
        resources/lib/jquery.ui/jquery.ui.datepicker.js on lines 376..387

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

        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

        Method showRevision has 176 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function showRevision( $timestamp ) {
                if ( !preg_match( '/[0-9]{14}/', $timestamp ) ) {
                    return;
                }
                $out = $this->getOutput();
        Severity: Major
        Found in includes/specials/SpecialUndelete.php - About 7 hrs to fix

          File MaintenanceRunner.php has 460 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace MediaWiki\Maintenance;
          
          use Exception;
          Severity: Minor
          Found in maintenance/includes/MaintenanceRunner.php - About 7 hrs to fix

            File checkStorage.php has 460 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Fsck for MediaWiki
             *
             * This program is free software; you can redistribute it and/or modify
            Severity: Minor
            Found in maintenance/storage/checkStorage.php - About 7 hrs to fix

              Session has 50 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Session implements \Countable, \Iterator, \ArrayAccess {
                  /** @var null|string[] Encryption algorithm to use */
                  private static $encryptionAlgorithm = null;
              
                  /** @var SessionBackend Session backend */
              Severity: Minor
              Found in includes/session/Session.php - About 7 hrs to fix

                Method find_middle_snake has 174 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function find_middle_snake( $bottoml1, $topl1, $bottoml2, $topl2, &$V, &$snake ) {
                        $from = &$this->from;
                        $to = &$this->to;
                        $V0 = &$V[0];
                        $V1 = &$V[1];
                Severity: Major
                Found in includes/libs/Diff/DiffEngine.php - About 6 hrs to fix

                  Method parse has 174 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function parse( $rawData ) {
                          $parsed = iptcparse( $rawData );
                          $data = [];
                          if ( !is_array( $parsed ) ) {
                              return $data;
                  Severity: Major
                  Found in includes/media/IPTC.php - About 6 hrs to fix

                    File XmlDumpWriter.php has 456 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    /**
                     * XmlDumpWriter
                     *
                     * Copyright © 2003, 2005, 2006 Brooke Vibber <bvibber@wikimedia.org>
                    Severity: Minor
                    Found in includes/export/XmlDumpWriter.php - About 6 hrs to fix

                      File URL.js has 455 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /* global Symbol */
                      // URL Polyfill
                      // Draft specification: https://url.spec.whatwg.org
                      
                      // Notes:
                      Severity: Minor
                      Found in resources/lib/url/URL.js - About 6 hrs to fix

                        Method doGuessMimeType has 173 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function doGuessMimeType( string $file ) {
                                // Read a chunk of the file
                                AtEase::suppressWarnings();
                                $f = fopen( $file, 'rb' );
                                AtEase::restoreWarnings();
                        Severity: Major
                        Found in includes/libs/mime/MimeAnalyzer.php - About 6 hrs to fix

                          Method getDefaultText has 173 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function getDefaultText() {
                                  if ( !$this->values['wgImageMagickConvertCommand'] ) {
                                      $this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert';
                                      $magic = '#';
                                  } else {
                          Severity: Major
                          Found in includes/installer/LocalSettingsGenerator.php - About 6 hrs to fix

                            Function getInclusiveMetrics has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function getInclusiveMetrics() {
                                    if ( $this->inclusive === null ) {
                                        $main = $this->hieraData['main()'];
                                        $hasCpu = isset( $main['cpu'] );
                                        $hasMu = isset( $main['mu'] );
                            Severity: Minor
                            Found in includes/libs/XhprofData.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 recentChangesBlockGroup has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                            Open

                                protected function recentChangesBlockGroup( $block ) {
                                    $recentChangesFlags = $this->getConfig()->get( MainConfigNames::RecentChangesFlags );
                            
                                    # Add the namespace and title of the block as part of the class
                                    $tableClasses = [ 'mw-enhanced-rc', 'mw-changeslist-line' ];
                            Severity: Minor
                            Found in includes/recentchanges/EnhancedChangesList.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

                            Severity
                            Category
                            Status
                            Source
                            Language