wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function fetchFirstLetterData has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function fetchFirstLetterData() {
        // Generate data from serialized data file
        if ( isset( self::TAILORING_FIRST_LETTERS[$this->locale] ) ) {
            $letters = require __DIR__ . "/data/first-letters-root.php";
            // Append additional characters
Severity: Minor
Found in includes/collation/IcuCollation.php - About 3 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 moveInconsistentPage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    protected function moveInconsistentPage( $row, Title $title ) {
        $titleImpossible = $title->getInterwiki() || !$title->canExist();
        if ( $title->exists( IDBAccessObject::READ_LATEST ) || $titleImpossible ) {
            if ( $titleImpossible ) {
                $prior = $title->getPrefixedDBkey();
Severity: Minor
Found in maintenance/cleanupTitles.php - About 3 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 ( this.local ) {
            ret.header = this.fullMonthNames[ dt.getMonth() + 1 ] + ' ' + dt.getFullYear();
            d = dt.getDay() % 7;
            e = this.getDaysInMonth( dt.getMonth() + 1, dt.getFullYear() );
        } else {
resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js on lines 679..683

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

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

        } else {
            ret.header = this.fullMonthNames[ dt.getUTCMonth() + 1 ] + ' ' + dt.getUTCFullYear();
            d = dt.getUTCDay() % 7;
            e = this.getDaysInMonth( dt.getUTCMonth() + 1, dt.getUTCFullYear() );
        }
resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js on lines 675..679

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

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

    var suffixes = {
        1: '-inci',
        5: '-inci',
        8: '-inci',
        70: '-inci',
Severity: Major
Found in resources/lib/moment/locale/az.js and 1 other location - About 3 hrs to fix
resources/lib/moment/locale/tr.js on lines 15..34

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

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

    var suffixes = {
        1: "'inci",
        5: "'inci",
        8: "'inci",
        70: "'inci",
Severity: Major
Found in resources/lib/moment/locale/tr.js and 1 other location - About 3 hrs to fix
resources/lib/moment/locale/az.js on lines 14..33

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

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 MessagesFr.php has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/** French (français)
 *
 * @file
 * @ingroup Languages
Severity: Minor
Found in languages/messages/MessagesFr.php - About 3 hrs to fix

    File generateCollationData.php has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Maintenance script to generate first letter data files for Collation.php.
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in maintenance/language/generateCollationData.php - About 3 hrs to fix

      Function adjustComponent has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          mw.widgets.datetime.ProlepticGregorianDateTimeFormatter.prototype.adjustComponent = function ( date, component, delta, mode ) {
              let min, max;
      
              if ( !( date instanceof Date ) ) {
                  date = this.defaultDate;

        Function getFieldForTag has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            mw.widgets.datetime.DateTimeFormatter.prototype.getFieldForTag = function ( tag, params ) {
                let c, spec = null;
        
                switch ( tag ) {
                    case 'intercalary':
        Severity: Major
        Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 3 hrs to fix

          Function WatchlistExpiryWidget has 81 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function WatchlistExpiryWidget( action, pageTitle, updateWatchLink, config ) {
              let dataExpiryOptions = require( './data.json' ).options,
                  messageLabel,
                  dropdownLabel,
                  expiryDropdown,
          Severity: Major
          Found in resources/src/mediawiki.watchstar.widgets/WatchlistExpiryWidget.js - About 3 hrs to fix

            Function buildHtml has 81 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    buildHtml: function () {
                        let $container, $bits, panes, paneId, gitInfoText, $gitInfo;
            
                        $container = $( '<div>' )
                            .attr( {
            Severity: Major
            Found in resources/src/mediawiki.debug/debug.js - About 3 hrs to fix

              Function processRelativeTime has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function processRelativeTime(number, withoutSuffix, key, isFuture) {
                      var result = number + ' ';
                      switch (key) {
                          case 's':
                              return withoutSuffix || isFuture
              Severity: Major
              Found in resources/lib/moment/locale/sl.js - About 3 hrs to fix

                Function relativeTimeMr has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function relativeTimeMr(number, withoutSuffix, string, isFuture) {
                        var output = '';
                        if (withoutSuffix) {
                            switch (string) {
                                case 's':
                Severity: Major
                Found in resources/lib/moment/locale/mr.js - About 3 hrs to fix

                  Function scrollIntoView has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  OO.ui.Element.static.scrollIntoView = function ( elOrPosition, config ) {
                      const deferred = $.Deferred();
                  
                      // Configuration initialization
                      config = config || {};
                  Severity: Major
                  Found in resources/lib/ooui/oojs-ui-core.js - About 3 hrs to fix

                    Function _keydown has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _keydown: function( event ) {
                            var match, prev, character, skip, regex,
                                preventDefault = true;
                    
                            function escape( value ) {
                    Severity: Major
                    Found in resources/lib/jquery.ui/jquery.ui.menu.js - About 3 hrs to fix

                      Method getModuleRegistrations has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getModuleRegistrations( Context $context ): string {
                              $resourceLoader = $context->getResourceLoader();
                              // Future developers: Use WebRequest::getRawVal() instead getVal().
                              // The getVal() method performs slow Language+UTF logic. (f303bb9360)
                              $safemode = $context->getRequest()->getRawVal( 'safemode' ) === '1';
                      Severity: Major
                      Found in includes/ResourceLoader/StartUpModule.php - About 3 hrs to fix

                        Method beginAccountCreation has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function beginAccountCreation( Authority $creator, array $reqs, $returnToUrl ) {
                                $session = $this->request->getSession();
                                if ( !$this->canCreateAccounts() ) {
                                    // Caller should have called canCreateAccounts()
                                    $session->remove( self::ACCOUNT_CREATION_STATE );
                        Severity: Major
                        Found in includes/auth/AuthManager.php - About 3 hrs to fix

                          Method writeSlot has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function writeSlot( SlotRecord $slot, $contentMode ) {
                                  $isMain = $slot->getRole() === SlotRecord::MAIN;
                                  $isV11 = $this->schemaVersion >= XML_DUMP_SCHEMA_VERSION_11;
                          
                                  if ( !$isV11 && !$isMain ) {
                          Severity: Major
                          Found in includes/export/XmlDumpWriter.php - About 3 hrs to fix

                            Method stream has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function stream(
                                    $headers = [], $sendErrors = true, $optHeaders = [], $flags = 0
                                ) {
                                    $headless = ( $flags & self::STREAM_HEADLESS );
                            
                            
                            Severity: Major
                            Found in includes/libs/filebackend/HTTPFileStreamer.php - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language