wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method makeThumbLink2 has 188 lines of code (exceeds 25 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: Major
Found in includes/linker/Linker.php - About 7 hrs to fix

    SelectQueryBuilder has 53 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SelectQueryBuilder extends JoinGroupBase {
    
        /** sort the results in ascending order */
        public const SORT_ASC = 'ASC';
    
    
    Severity: Major
    Found in includes/libs/rdbms/querybuilder/SelectQueryBuilder.php - About 7 hrs to fix

      Method run has 187 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function run( $resultPageSet = null ) {
              $params = $this->extractRequestParams();
      
              $categoryTitle = $this->getTitleOrPageId( $params )->getTitle();
              if ( $categoryTitle->getNamespace() !== NS_CATEGORY ) {
      Severity: Major
      Found in includes/api/ApiQueryCategoryMembers.php - About 7 hrs to fix

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

        $.ui.plugin.add("draggable", "zIndex", {
            start: function(event, ui) {
                var t = $(ui.helper), o = $(this).data("draggable").options;
                if(t.css("zIndex")) o._zIndex = t.css("zIndex");
                t.css('zIndex', o.zIndex);
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 7 hrs to fix
        resources/lib/jquery.ui/jquery.ui.draggable.js on lines 678..688

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

        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(!o.axis || o.axis != 'x') {
                        if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
                            i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
                        else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
                            i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 7 hrs to fix
        resources/lib/jquery.ui/jquery.ui.draggable.js on lines 708..713

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

        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

        OO.ui.mixin.IconElement.prototype.setIconElement = function ( $icon ) {
            if ( this.$icon ) {
                this.$icon
                    .removeClass( 'oo-ui-iconElement-icon oo-ui-icon-' + this.icon )
                    .removeAttr( 'title' );
        Severity: Major
        Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 7 hrs to fix
        resources/lib/ooui/oojs-ui-core.js on lines 3244..3260

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

        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

        $.ui.plugin.add("draggable", "opacity", {
            start: function(event, ui) {
                var t = $(ui.helper), o = $(this).data('draggable').options;
                if(t.css("opacity")) o._opacity = t.css("opacity");
                t.css('opacity', o.opacity);
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 7 hrs to fix
        resources/lib/jquery.ui/jquery.ui.draggable.js on lines 828..838

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

        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

        OO.ui.mixin.IndicatorElement.prototype.setIndicatorElement = function ( $indicator ) {
            if ( this.$indicator ) {
                this.$indicator
                    .removeClass( 'oo-ui-indicatorElement-indicator oo-ui-indicator-' + this.indicator )
                    .removeAttr( 'title' );
        Severity: Major
        Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 7 hrs to fix
        resources/lib/ooui/oojs-ui-core.js on lines 3104..3120

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

        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(!o.axis || o.axis != 'y') {
                        if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
                            i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
                        else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
                            i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 7 hrs to fix
        resources/lib/jquery.ui/jquery.ui.draggable.js on lines 701..706

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

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

            private function run( $resultPageSet = null ) {
                $repo = $this->mRepo;
                if ( !$repo instanceof LocalRepo ) {
                    $this->dieWithError( 'apierror-unsupportedrepo' );
                }
        Severity: Major
        Found in includes/api/ApiQueryAllImages.php - About 7 hrs to fix

          Method setupAttributesAllowedInternal has 186 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function setupAttributesAllowedInternal(): array {
                  static $allowed;
          
                  if ( $allowed !== null ) {
                      return $allowed;
          Severity: Major
          Found in includes/parser/Sanitizer.php - About 7 hrs to fix

            Function exportExtractedData has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function exportExtractedData( array $info ) {
                    if ( $info['globals'] ) {
                        // Create a copy of the keys to allow fast access via isset also for null values
                        // Since php8.1 always a read-only copy is created when the whole object is passed on function calls
                        // (like for array_key_exists). See T366547 - https://wiki.php.net/rfc/restrict_globals_usage
            Severity: Minor
            Found in includes/registration/ExtensionRegistry.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 formatRow has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
            Open

                public function formatRow( $row ) {
                    $ret = '';
                    $classes = [];
                    $attribs = [];
                    $authority = $this->getAuthority();
            Severity: Minor
            Found in includes/pager/ContributionsPager.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 splitTitleString has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
            Open

                public function splitTitleString( $text, $defaultNamespace = NS_MAIN ) {
                    $dbkey = str_replace( ' ', '_', $text );
            
                    # Initialisation
                    $parts = [
            Severity: Minor
            Found in includes/title/MediaWikiTitleCodec.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 run has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
            Open

                private function run( $resultPageSet = null ) {
                    $pages = $this->getPageSet()->getGoodPages();
                    if ( $pages === [] ) {
                        return; // nothing to do
                    }
            Severity: Minor
            Found in includes/api/ApiQueryCategories.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 setup has 184 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              setup(props, { emit, attrs }) {
                const rootElement = ref();
                const statusMessageContent = ref("");
                const computedDirection = useComputedDirection(rootElement);
                const input = ref();
            Severity: Major
            Found in resources/lib/codex/codex.js - About 7 hrs to fix

              Method applyTransformations has 184 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected static function applyTransformations( array $dataIn, array $transforms ) {
                      $strip = $transforms['Strip'] ?? 'none';
                      if ( $strip === 'base' ) {
                          $transforms['Strip'] = 'none';
                      }
              Severity: Major
              Found in includes/api/ApiResult.php - About 7 hrs to fix

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

                    public function execute() {
                        $db = $this->getDB();
                        $params = $this->extractRequestParams();
                        $this->requireMaxOneParameter( $params, 'userids', 'users' );
                
                
                Severity: Major
                Found in includes/api/ApiQueryUsers.php - About 7 hrs to fix

                  WikiRevision has 52 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class WikiRevision implements ImportableUploadRevision, ImportableOldRevision {
                  
                      /**
                       * @since 1.2
                       * @var Title
                  Severity: Major
                  Found in includes/import/WikiRevision.php - About 7 hrs to fix

                    DatabasePostgres has 52 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class DatabasePostgres extends Database {
                        /** @var int */
                        private $port;
                        /** @var string */
                        private $tempSchema;
                    Severity: Major
                    Found in includes/libs/rdbms/database/DatabasePostgres.php - About 7 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language