wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

        calendar: {
            sameDay: '[dnes v] LT',
            nextDay: '[zítra v] LT',
            nextWeek: function () {
                switch (this.day()) {
Severity: Major
Found in resources/lib/moment/locale/cs.js and 1 other location - About 6 hrs to fix
resources/lib/moment/locale/sk.js on lines 90..128

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

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 40 (exceeds 5 allowed). Consider refactoring.
Open

  setup(props, { emit }) {
    const labelId = useGeneratedId("dialog-label");
    const backdrop = ref();
    const dialogElement = ref();
    const dialogBody = ref();
Severity: Minor
Found in resources/lib/codex/codex.js - 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 buildContent has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function buildContent( Context $context ) {
        $statsFactory = MediaWikiServices::getInstance()->getStatsFactory();
        $statStart = microtime( true );

        // This MUST build both scripts and styles, regardless of whether $context->getOnly()
Severity: Minor
Found in includes/ResourceLoader/Module.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 mergeFieldInfo has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    public static function mergeFieldInfo( array $reqs ) {
        $merged = [];

        // fields that are required by some primary providers but not others are not actually required
        $sharedRequiredPrimaryFields = null;
Severity: Minor
Found in includes/auth/AuthenticationRequest.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 loadUnguarded has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadUnguarded( $code, $mode ) {
        $success = false; // Keep track of success
        $staleCache = false; // a cache array with expired data, or false if none has been loaded
        $where = []; // Debug info, delayed to avoid spamming debug log too much

Severity: Minor
Found in includes/language/MessageCache.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 getFieldDefinitions has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getFieldDefinitions( array $fieldInfo ) {
        $isLoggedIn = $this->getUser()->isRegistered();
        $continuePart = $this->isContinued() ? 'continue-' : '';
        $anotherPart = $isLoggedIn ? 'another-' : '';
        // @phan-suppress-next-line PhanUndeclaredMethod
Severity: Minor
Found in includes/specialpage/LoginSignupSpecialPage.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 getCurrentUserInfo has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getCurrentUserInfo() {
        $user = $this->getUser();
        $vals = [];
        $vals['id'] = $user->getId();
        $vals['name'] = $user->getName();
Severity: Minor
Found in includes/api/ApiQueryUserInfo.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 parseParameters has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseParameters( $params ) {
        $prop = array_fill_keys( $params['prop'], true );

        $this->fld_ids = isset( $prop['ids'] );
        $this->fld_flags = isset( $prop['flags'] );
Severity: Minor
Found in includes/api/ApiQueryRevisionsBase.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 setVals has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    private function setVals( &$vals, $prefix, $rev ) {
        if ( $rev ) {
            $title = Title::newFromLinkTarget( $rev->getPageAsLinkTarget() );
            if ( isset( $this->props['ids'] ) ) {
                $vals["{$prefix}id"] = $title->getArticleID();
Severity: Minor
Found in includes/api/ApiComparePages.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 executeInternal has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    private function executeInternal( $isDryRun ) {
        $generatorName = $this->mAllowGenerator ? $this->mParams['generator'] : null;
        if ( isset( $generatorName ) ) {
            $dbSource = $this->mDbSource;
            if ( !$dbSource instanceof ApiQuery ) {
Severity: Minor
Found in includes/api/ApiPageSet.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 getNearMatchInternal has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getNearMatchInternal( $searchterm ) {
        $allSearchTerms = [ $searchterm ];

        if ( $this->languageConverter->hasVariants() ) {
            $allSearchTerms = array_unique( array_merge(
Severity: Minor
Found in includes/search/TitleMatcher.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 execute has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        # Change to current working directory
        $oldCwd = getcwd();
        chdir( $oldCwd );

Severity: Minor
Found in maintenance/deleteBatch.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 main has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    public function main() {
        $services = $this->getServiceContainer();
        $contLang = $services->getContentLanguage();
        $langConverter = $services->getLanguageConverterFactory()->getLanguageConverter( $contLang );
        $serverUrl = $services->getUrlUtils()->getServer( PROTO_CANONICAL ) ?? '';
Severity: Minor
Found in maintenance/generateSitemap.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

Method getChunkResult has 152 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getChunkResult( $warnings ) {
        $result = [];

        if ( $warnings && count( $warnings ) > 0 ) {
            $result['warnings'] = $warnings;
Severity: Major
Found in includes/api/ApiUpload.php - About 6 hrs to fix

    Method showResults has 152 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function showResults( $term ) {
            if ( $this->searchEngineType !== null ) {
                $this->setExtraParam( 'srbackend', $this->searchEngineType );
            }
    
    
    Severity: Major
    Found in includes/specials/SpecialSearch.php - About 6 hrs to fix

      File categoryChangesAsRdf.php has 418 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: Minor
      Found in maintenance/categoryChangesAsRdf.php - About 6 hrs to fix

        ApiHookRunner has 44 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ApiHookRunner implements
            Hook\APIAfterExecuteHook,
            Hook\ApiCheckCanExecuteHook,
            Hook\ApiDeprecationHelpHook,
            Hook\ApiLogFeatureUsageHook,
        Severity: Minor
        Found in includes/api/ApiHookRunner.php - About 6 hrs to fix

          Linker has 44 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Linker {
              /**
               * Flags for userToolLinks()
               */
              public const TOOL_LINKS_NOBLOCK = 1;
          Severity: Minor
          Found in includes/linker/Linker.php - About 6 hrs to fix

            SearchEngine has 44 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class SearchEngine {
                public const DEFAULT_SORT = 'relevance';
            
                /** @var string */
                public $prefix = '';
            Severity: Minor
            Found in includes/search/SearchEngine.php - About 6 hrs to fix

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

                                _ctx.highlightQuery ? (openBlock(), createBlock(_component_cdx_search_result_title, {
                                  key: 0,
                                  title: _ctx.match,
                                  "search-query": _ctx.searchQuery,
                                  lang: (_c = _ctx.language) == null ? void 0 : _c.match
              Severity: Major
              Found in resources/lib/codex/codex.js and 1 other location - About 6 hrs to fix
              resources/lib/codex/codex.js on lines 2349..2366

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

              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

              Severity
              Category
              Status
              Source
              Language