wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
includes/ApiVisualEditorEdit.php

Summary

Maintainability
F
3 days
Test Coverage

File ApiVisualEditorEdit.php has 470 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Parsoid/RESTBase+MediaWiki API wrapper.
 *
 * @file
Severity: Minor
Found in includes/ApiVisualEditorEdit.php - About 7 hrs to fix

    Function execute has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute() {
            $user = $this->getUser();
            $params = $this->extractRequestParams();
    
            $result = [];
    Severity: Minor
    Found in includes/ApiVisualEditorEdit.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 execute has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function execute() {
            $user = $this->getUser();
            $params = $this->extractRequestParams();
    
            $result = [];
    Severity: Major
    Found in includes/ApiVisualEditorEdit.php - About 5 hrs to fix

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

          public function getAllowedParams() {
              return [
                  'paction' => [
                      ParamValidator::PARAM_REQUIRED => true,
                      ParamValidator::PARAM_TYPE => [
      Severity: Major
      Found in includes/ApiVisualEditorEdit.php - About 2 hrs to fix

        Method parseWikitext has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function parseWikitext( $newRevId, array $params ) {
                $apiParams = [
                    'action' => 'parse',
                    'oldid' => $newRevId,
                    'prop' => 'text|revid|categorieshtml|sections|displaytitle|subtitle|modules|jsconfigvars',
        Severity: Minor
        Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

          Method diffWikitext has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function diffWikitext( Title $title, ?int $fromId, $wikitext, $section = null ) {
                  $apiParams = [
                      'action' => 'compare',
                      'prop' => 'diff',
                      // Because we're just providing wikitext, we only care about the main slot
          Severity: Minor
          Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

            Method saveWikitext has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function saveWikitext( Title $title, $wikitext, $params ) {
                    $apiParams = [
                        'action' => 'edit',
                        'title' => $title->getPrefixedDBkey(),
                        'text' => $wikitext,
            Severity: Minor
            Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

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

                      ApiMain $main,
                      string $name,
                      HookContainer $hookContainer,
                      IBufferingStatsdDataFactory $statsdDataFactory,
                      PageEditStash $pageEditStash,
              Severity: Major
              Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

                There are no issues that match your filters.

                Category
                Status