wikimedia/mediawiki-core

View on GitHub

Showing 11,461 of 11,461 total issues

Function makeApi has 332 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function makeApi(sinon) {
        var push = [].push;
        var match = sinon.match;

        function mock(object) {
Severity: Major
Found in resources/lib/sinonjs/sinon.js - About 1 day to fix

    Function Assert has 330 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var Assert = /*#__PURE__*/function () {
        function Assert(testContext) {
          _classCallCheck(this, Assert);
          this.test = testContext;
        }
    Severity: Major
    Found in resources/lib/qunitjs/qunit.js - About 1 day to fix

      Function profilePreferences has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function profilePreferences(
              User $user, IContextSource $context, &$defaultPreferences
          ) {
              // retrieving user name for GENDER and misc.
              $userName = $user->getName();
      Severity: Minor
      Found in includes/preferences/DefaultPreferencesFactory.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

              'default' =>
                  // This array should be sorted by key
                  [
                      'ccmeonemails' => 0,
                      'date' => 'default',
      Severity: Major
      Found in includes/MainConfigSchema.php and 1 other location - About 1 day to fix
      includes/config-schema.php on lines 1048..1116

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

      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

                  'DefaultUserOptions' => [
                      'ccmeonemails' => 0,
                      'date' => 'default',
                      'diffonly' => 0,
                      'diff-type' => 'table',
      Severity: Major
      Found in includes/config-schema.php and 1 other location - About 1 day to fix
      includes/MainConfigSchema.php on lines 7419..7489

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

      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

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

          _adjustOffsetFromHelper: function(obj) {
              if (typeof obj == 'string') {
                  obj = obj.split(' ');
              }
              if (Array.isArray(obj)) {
      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 288..307

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

      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

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

          _adjustOffsetFromHelper: function(obj) {
              if (typeof obj == 'string') {
                  obj = obj.split(' ');
              }
              if (Array.isArray(obj)) {
      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 796..815

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

      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 continueAccountCreation has 326 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function continueAccountCreation( array $reqs ) {
              $session = $this->request->getSession();
              try {
                  if ( !$this->canCreateAccounts() ) {
                      // Caller should have called canCreateAccounts()
      Severity: Major
      Found in includes/auth/AuthManager.php - About 1 day to fix

        File ContributionsSpecialPage.php has 707 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Implements Special:Contributions
         *
         * This program is free software; you can redistribute it and/or modify
        Severity: Major
        Found in includes/specialpage/ContributionsSpecialPage.php - About 1 day to fix

          File SpecialBlock.php has 707 lines of code (exceeds 250 allowed). 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/specials/SpecialBlock.php - About 1 day to fix

            Function parse has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function parse( $rawData ) {
                    $parsed = iptcparse( $rawData );
                    $data = [];
                    if ( !is_array( $parsed ) ) {
                        return $data;
            Severity: Minor
            Found in includes/media/IPTC.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 makeThumbLink2 has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function makeThumbLink2(
                    LinkTarget $title, $file, $frameParams = [], $handlerParams = [],
                    $time = false, $query = '', array $classes = [], ?Parser $parser = null
                ) {
                    $exists = $file && $file->exists();
            Severity: Minor
            Found in includes/linker/Linker.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

            File ApiQueryRevisionsBase.php has 703 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
             *
             * This program is free software; you can redistribute it and/or modify
            Severity: Major
            Found in includes/api/ApiQueryRevisionsBase.php - About 1 day to fix

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

                  public function execute() {
                      // Before doing anything at all, let's check permissions
                      $this->checkUserRightsAny( 'deletedhistory' );
              
                      $this->addDeprecation( 'apiwarn-deprecation-deletedrevs', 'action=query&list=deletedrevs' );
              Severity: Major
              Found in includes/api/ApiQueryDeletedrevs.php - About 1 day to fix

                File Controller.js has 699 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                var byteLength = require( 'mediawiki.String' ).byteLength,
                    UriProcessor = require( './UriProcessor.js' ),
                    Controller;
                
                /* eslint no-underscore-dangle: "off" */
                Severity: Major
                Found in resources/src/mediawiki.rcfilters/Controller.js - About 1 day to fix

                  Function toHTML has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function toHTML() {
                          $resolveFilesViaParser = $this->mParser instanceof Parser;
                          if ( $resolveFilesViaParser ) {
                              $parserOutput = $this->mParser->getOutput();
                              $repoGroup = null;
                  Severity: Minor
                  Found in includes/gallery/TraditionalImageGallery.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

                  CoreParserFunctions has 84 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class CoreParserFunctions {
                      /** @var int Assume that no output will later be saved this many seconds after parsing */
                      private const MAX_TTS = 900;
                  
                      /**
                  Severity: Major
                  Found in includes/parser/CoreParserFunctions.php - About 1 day to fix

                    FileRepo has 84 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class FileRepo {
                        public const DELETE_SOURCE = 1;
                        public const OVERWRITE = 2;
                        public const OVERWRITE_SAME = 4;
                        public const SKIP_LOCKING = 8;
                    Severity: Major
                    Found in includes/filerepo/FileRepo.php - About 1 day to fix

                      File oojs.js has 693 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /*!
                       * OOjs v7.0.1
                       * https://www.mediawiki.org/wiki/OOjs
                       *
                       * Copyright 2011-2023 OOjs Team and other contributors.
                      Severity: Major
                      Found in resources/lib/oojs/oojs.js - About 1 day to fix

                        File ParsoidHandler.php has 693 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        /**
                         * Copyright (C) 2011-2020 Wikimedia Foundation and others.
                         *
                         * This program is free software; you can redistribute it and/or modify
                        Severity: Major
                        Found in includes/Rest/Handler/ParsoidHandler.php - About 1 day to fix
                          Severity
                          Category
                          Status
                          Source
                          Language