wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

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

    public function getMonthNameUnlocalizer() {
        $languageCode = $this->options->getOption( ValueParser::OPT_LANG );

        if ( $languageCode === self::CANONICAL_LANGUAGE_CODE ) {
            $replacements = [];
Severity: Minor
Found in repo/includes/Parsers/TimeParserFactory.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 applyGlobals has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function applyGlobals() {
        $optionsData = $this->getOption( 'options', 'false' );
        if ( substr_compare( $optionsData, 'B64://', 0, strlen( 'B64://' ) ) === 0 ) {
            $optionsData = base64_decode( substr( $optionsData, strlen( 'B64://' ) ) );
        }
Severity: Minor
Found in repo/maintenance/searchEntities.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

Method saveEntity has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        EntityDocument $entity,
        $summary,
        User $user,
        $flags = 0,
        $baseRevId = false,
Severity: Minor
Found in repo/includes/EditEntity/StatsdSaveTimeRecordingEntityStore.php - About 45 mins to fix

    Method build has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            OutputPage $out,
            $rightsUrl,
            $rightsText,
            array $badgeItems,
            $stringLimit,
    Severity: Minor
    Found in repo/includes/OutputPageJsConfigBuilder.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if ( isset( $date['second'] ) ) {
                                  $precision = TimeValue::PRECISION_SECOND;
                                  $time[5] = $this->parseFormattedNumber( $date['second'] );
                              }
      Severity: Major
      Found in repo/includes/Parsers/DateFormatParser.php - About 45 mins to fix

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

            private function chooseAndParseNumber( Language $lang, $matches, $precision, $isBceMsg ) {
                $year = null;
                foreach ( $matches as $number ) {
                    if ( $number === '' ) {
                        continue;
        Severity: Minor
        Found in repo/includes/Parsers/MwTimeIsoParser.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

        Method saveRedirect has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                EntityRedirect $redirect,
                $summary,
                User $user,
                $flags = 0,
                $baseRevId = false,
        Severity: Minor
        Found in repo/includes/EditEntity/StatsdSaveTimeRecordingEntityStore.php - About 45 mins to fix

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

              public function getEntity( $expectedClass = EntityDocument::class ) {
                  if ( !$this->entity ) {
                      $this->entity = $this->codec->decodeEntity( $this->blob, $this->contentFormat );
          
                      if ( !( $this->entity instanceof EntityDocument ) ) {
          Severity: Minor
          Found in repo/includes/Content/DeferredDecodingEntityHolder.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

          Method attemptSave has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  EntityDocument $newEntity,
                  string $summary,
                  $flags,
                  $token,
                  $watch = null,
          Severity: Minor
          Found in repo/includes/EditEntity/EditEntity.php - About 45 mins to fix

            Method attemptSave has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
            Severity: Minor
            Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 45 mins to fix

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

                  private function getRegexpsFromMessageText( string $msgText ): array {
                      static $pluralRegex = null;
                      if ( $pluralRegex === null ) {
                          // We need to match on a preg_quoted string here, so double quote
                          $pluralRegex = '@' . preg_quote( preg_quote( '{{PLURAL:$1|' ) ) .
              Severity: Minor
              Found in repo/includes/Parsers/MwTimeIsoParser.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 deserialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function deserialize( string $dataTypeId, array $valueSerialization, string $basePath = '' ): DataValue {
                      $this->assertFieldExists( $valueSerialization, 'content', $basePath );
              
                      // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.Found
                      switch ( $dataValueType = $this->valueTypeLookup->getValueType( $dataTypeId ) ) {
              Severity: Minor
              Found in repo/rest-api/src/Infrastructure/DataValuesValueDeserializer.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function execute(): void {
                      if ( !WikibaseSettings::isRepoEnabled() ) {
                          $this->output( "You need to have Wikibase enabled in order to use this maintenance script!\n\n" );
                          exit;
                      }
              Severity: Minor
              Found in repo/maintenance/rebuildItemsPerSite.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

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

                      ItemId $id,
                      Labels $labels,
                      Descriptions $descriptions,
                      Aliases $aliases,
                      Sitelinks $sitelinks,
              Severity: Minor
              Found in repo/rest-api/src/Domain/ReadModel/Item.php - About 45 mins to fix

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

                    private function assertValidStatements(
                        array $statementsSerialization,
                        Property $originalProperty,
                        array $originalStatementsSerialization
                    ): void {

                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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        string $propertyId,
                        array $patch,
                        array $editTags,
                        bool $isBot,
                        ?string $comment,

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

                          LabelsSyntaxValidator $labelsSyntaxValidator,
                          PropertyLabelsContentsValidator $labelsContentsValidator,
                          DescriptionsSyntaxValidator $descriptionsSyntaxValidator,
                          PropertyDescriptionsContentsValidator $descriptionsContentsValidator,
                          AliasesValidator $aliasesValidator,

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

                            string $propertyId,
                            string $languageCode,
                            array $editTags,
                            bool $isBot,
                            ?string $comment,

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

                              PropertyId $id,
                              string $dataType,
                              Labels $labels,
                              Descriptions $descriptions,
                              Aliases $aliases,
                      Severity: Minor
                      Found in repo/rest-api/src/Domain/ReadModel/Property.php - About 45 mins to fix

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

                            public function getHtml( StatementList $statementList ) {
                                $statementLists = $this->statementGrouper->groupStatements( $statementList );
                                $html = '';
                        
                                foreach ( $statementLists as $key => $statements ) {
                        Severity: Minor
                        Found in view/src/StatementSectionsView.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

                        Severity
                        Category
                        Status
                        Source
                        Language