wikimedia/mediawiki-core

View on GitHub
includes/api/ApiQueryRevisionsBase.php

Summary

Maintainability
F
1 wk
Test Coverage

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

    Function extractDeprecatedContent has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

        private function extractDeprecatedContent( Content $content, RevisionRecord $revision ) {
            $vals = [];
            $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
    
            if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
    Severity: Minor
    Found in includes/api/ApiQueryRevisionsBase.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 extractRevisionInfo has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function extractRevisionInfo( RevisionRecord $revision, $row ) {
            $vals = [];
            $anyHidden = false;
    
            if ( $this->fld_ids ) {
    Severity: Minor
    Found in includes/api/ApiQueryRevisionsBase.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 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

    Method extractDeprecatedContent has 130 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function extractDeprecatedContent( Content $content, RevisionRecord $revision ) {
            $vals = [];
            $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
    
            if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
    Severity: Major
    Found in includes/api/ApiQueryRevisionsBase.php - About 5 hrs to fix

      Method parseParameters has 119 lines of code (exceeds 25 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: Major
      Found in includes/api/ApiQueryRevisionsBase.php - About 4 hrs to fix

        Method extractRevisionInfo has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function extractRevisionInfo( RevisionRecord $revision, $row ) {
                $vals = [];
                $anyHidden = false;
        
                if ( $this->fld_ids ) {
        Severity: Major
        Found in includes/api/ApiQueryRevisionsBase.php - About 4 hrs to fix

          Method getAllowedParams has 105 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getAllowedParams() {
                  $slotRoles = $this->slotRoleRegistry->getKnownRoles();
                  sort( $slotRoles, SORT_STRING );
                  $smallLimit = $this->getMain()->canApiHighLimits() ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_SML1;
          
          
          Severity: Major
          Found in includes/api/ApiQueryRevisionsBase.php - About 4 hrs to fix

            Function extractSlotInfo has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

                private function extractSlotInfo( SlotRecord $slot, $revDel, &$content = null ) {
                    $vals = [];
                    ApiResult::setArrayType( $vals, 'assoc' );
            
                    if ( $this->fld_slotsize ) {
            Severity: Minor
            Found in includes/api/ApiQueryRevisionsBase.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 extractAllSlotInfo has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                private function extractAllSlotInfo( RevisionRecord $revision, $revDel ): array {
                    $vals = [];
            
                    if ( $this->slotRoles === null ) {
                        try {
            Severity: Minor
            Found in includes/api/ApiQueryRevisionsBase.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

            Method extractAllSlotInfo has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function extractAllSlotInfo( RevisionRecord $revision, $revDel ): array {
                    $vals = [];
            
                    if ( $this->slotRoles === null ) {
                        try {
            Severity: Major
            Found in includes/api/ApiQueryRevisionsBase.php - About 2 hrs to fix

              Method __construct has 13 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      ApiQuery $queryModule,
                      $moduleName,
                      $paramPrefix = '',
                      RevisionStore $revisionStore = null,
                      IContentHandlerFactory $contentHandlerFactory = null,
              Severity: Major
              Found in includes/api/ApiQueryRevisionsBase.php - About 1 hr to fix

                Method extractSlotInfo has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function extractSlotInfo( SlotRecord $slot, $revDel, &$content = null ) {
                        $vals = [];
                        ApiResult::setArrayType( $vals, 'assoc' );
                
                        if ( $this->fld_slotsize ) {
                Severity: Minor
                Found in includes/api/ApiQueryRevisionsBase.php - About 1 hr to fix

                  There are no issues that match your filters.

                  Category
                  Status