wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/Api/ParseValue.php

Summary

Maintainability
C
1 day
Test Coverage

File ParseValue.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

namespace Wikibase\Repo\Api;
Severity: Minor
Found in repo/includes/Api/ParseValue.php - About 2 hrs to fix

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

        private function getParser(): ValueParser {
            $params = $this->extractRequestParams();
    
            $options = $this->getOptionsObject( $params['options'] );
    
    
    Severity: Minor
    Found in repo/includes/Api/ParseValue.php - About 1 hr to fix

      Method factory has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              ApiMain $mainModule,
              string $moduleName,
              IBufferingStatsdDataFactory $stats,
              ApiHelperFactory $apiHelperFactory,
              DataTypeFactory $dataTypeFactory,
      Severity: Major
      Found in repo/includes/Api/ParseValue.php - About 1 hr to fix

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

                ApiMain $mainModule,
                string $moduleName,
                DataTypeFactory $dataTypeFactory,
                ValueParserFactory $valueParserFactory,
                DataTypeValidatorFactory $dataTypeValidatorFactory,
        Severity: Major
        Found in repo/includes/Api/ParseValue.php - About 1 hr to fix

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

              public function getAllowedParams(): array {
                  return [
                      'datatype' => [
                          ParamValidator::PARAM_TYPE => $this->dataTypeFactory->getTypeIds(),
                          ParamValidator::PARAM_REQUIRED => false,
          Severity: Minor
          Found in repo/includes/Api/ParseValue.php - About 1 hr to fix

            Method parseStringValue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function parseStringValue( ValueParser $parser, string $value, ?ValueValidator $validator ): array {
                    $result = [
                        'raw' => $value,
                    ];
            
            
            Severity: Minor
            Found in repo/includes/Api/ParseValue.php - About 1 hr to fix

              Function getParser has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getParser(): ValueParser {
                      $params = $this->extractRequestParams();
              
                      $options = $this->getOptionsObject( $params['options'] );
              
              
              Severity: Minor
              Found in repo/includes/Api/ParseValue.php - About 45 mins 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 parseStringValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function parseStringValue( ValueParser $parser, string $value, ?ValueValidator $validator ): array {
                      $result = [
                          'raw' => $value,
                      ];
              
              
              Severity: Minor
              Found in repo/includes/Api/ParseValue.php - About 25 mins 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 getOptionsObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getOptionsObject( ?string $optionsParam ): ParserOptions {
                      $parserOptions = new ParserOptions();
                      $parserOptions->setOption( ValueParser::OPT_LANG, $this->getLanguage()->getCode() );
              
                      if ( is_string( $optionsParam ) && $optionsParam !== '' ) {
              Severity: Minor
              Found in repo/includes/Api/ParseValue.php - About 25 mins 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

              There are no issues that match your filters.

              Category
              Status