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

            if ( factor.from.y !== factor.to.y ) {
                child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
                child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
            }
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.effect-scale.js and 1 other location - About 3 hrs to fix
resources/lib/jquery.ui/jquery.ui.effect-scale.js on lines 255..258

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

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

    _hoverable: function( element ) {
        this.hoverable = this.hoverable.add( element );
        this._on( element, {
            mouseenter: function( event ) {
                $( event.currentTarget ).addClass( "ui-state-hover" );
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.widget.js and 1 other location - About 3 hrs to fix
resources/lib/jquery.ui/jquery.ui.widget.js on lines 443..453

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

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

        relativeTime: {
            future: function (s) {
                return (/^[0-9].+$/.test(s) ? 'tra' : 'in') + ' ' + s;
            },
            past: '%s fa',
Severity: Major
Found in resources/lib/moment/locale/it.js and 1 other location - About 3 hrs to fix
resources/lib/moment/locale/it-ch.js on lines 47..64

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

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

        if ( $type == RC_LOG ) {
            $data['logEntry'] = $this->insertLogEntry( $rcObj );
        } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
            $data['comment'] = $this->insertComment( $rcObj );
        } else {
Severity: Major
Found in includes/recentchanges/EnhancedChangesList.php and 1 other location - About 3 hrs to fix
includes/recentchanges/EnhancedChangesList.php on lines 672..684

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

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

        if ( $type == RC_LOG ) {
            $data['logEntry'] = $this->insertLogEntry( $rcObj );
        } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
            $data['comment'] = $this->insertComment( $rcObj );
        } else {
Severity: Major
Found in includes/recentchanges/EnhancedChangesList.php and 1 other location - About 3 hrs to fix
includes/recentchanges/EnhancedChangesList.php on lines 424..438

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

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

<?php
/** Zazaki (Zazaki)
 *
 * @file
 * @ingroup Languages
Severity: Minor
Found in languages/messages/MessagesDiq.php - About 3 hrs to fix

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

        parse = function ( title, defaultNamespace ) {
            let namespace = defaultNamespace === undefined ? NS_MAIN : defaultNamespace;
    
            title = title
                // Strip Unicode bidi override characters
    Severity: Minor
    Found in resources/src/mediawiki.Title/Title.js - 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 exports has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function ( $inlineToggleSwitchLayout ) {
        let $wikitextDiffContainer, $wikitextDiffHeader, $wikitextDiffBody,
            $wikitextDiffBodyInline, $wikitextDiffBodyTable,
            url = new URL( location.href ),
            api = new mw.Api(),
    Severity: Minor
    Found in resources/src/mediawiki.diff/inlineFormatToggle.js - 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 setup has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      setup(props, { emit, attrs }) {
        const handle = ref();
        const menu = ref();
        const descriptionId = inject(FieldDescriptionIdKey, void 0);
        const menuId = useGeneratedId("select-menu");
    Severity: Minor
    Found in resources/lib/codex/codex.js - 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 doNormalizeJsonSchema has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function doNormalizeJsonSchema(
            array $schema,
            array &$defs,
            string $source,
            string $propertyName,
    Severity: Minor
    Found in includes/Settings/Source/JsonSchemaTrait.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 getEmptySessionInternal has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getEmptySessionInternal( WebRequest $request = null, $id = null ) {
            if ( $id !== null ) {
                if ( !self::validateSessionId( $id ) ) {
                    throw new InvalidArgumentException( 'Invalid session ID' );
                }
    Severity: Minor
    Found in includes/session/SessionManager.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 doQuery has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function doQuery() {
            if ( $this->mQueryDone ) {
                return;
            }
            $this->mImg = $this->mImagePage->getPage()->getFile(); // ensure loading
    Severity: Minor
    Found in includes/page/ImageHistoryPseudoPager.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 getModuleRegistrations has a Cognitive Complexity of 25 (exceeds 5 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: Minor
    Found in includes/ResourceLoader/StartUpModule.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 assessConnectionLoss has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function assessConnectionLoss(
            string $verb,
            float $walltime,
            CriticalSessionInfo $priorSessInfo
        ) {
    Severity: Minor
    Found in includes/libs/rdbms/database/Database.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 buildPersonalUrls has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function buildPersonalUrls( bool $includeNotifications = true ) {
            $this->setupTemplateContext();
            $title = $this->getTitle();
            $authority = $this->getAuthority();
            $request = $this->getRequest();
    Severity: Minor
    Found in includes/skins/SkinTemplate.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 getNamespaceAliases has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getNamespaceAliases() {
            if ( $this->namespaceAliases === null ) {
                $aliases = $this->localisationCache->getItem( $this->mCode, 'namespaceAliases' );
                if ( !$aliases ) {
                    $aliases = [];
    Severity: Minor
    Found in includes/language/Language.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 getOptionFromUser has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getOptionFromUser( $name, $info, array $userOptions ) {
            $val = $userOptions[$name] ?? null;
    
            // Handling for multiselect preferences
            if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
    Severity: Minor
    Found in includes/preferences/DefaultPreferencesFactory.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 transformImageMagickExt has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function transformImageMagickExt( $image, $params ) {
            $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
            $sharpenReductionThreshold = $mainConfig->get( MainConfigNames::SharpenReductionThreshold );
            $sharpenParameter = $mainConfig->get( MainConfigNames::SharpenParameter );
            $maxAnimatedGifArea = $mainConfig->get( MainConfigNames::MaxAnimatedGifArea );
    Severity: Minor
    Found in includes/media/BitmapHandler.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 submit has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function submit() {
            global $wgPasswordPolicy;
    
            $retVal = true;
            $this->parent->setVarsFromRequest( [ 'wgSitename', '_NamespaceType',
    Severity: Minor
    Found in includes/installer/WebInstallerName.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 execute has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute( $par ) {
            $this->checkPermissions();
    
            $this->setHeaders();
            $this->outputHeader();
    Severity: Minor
    Found in includes/specialpage/QueryPage.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

    Severity
    Category
    Status
    Source
    Language