wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

        if ( !$result->isValid() ) {
            $error = $result->getErrors()[0];
            switch ( $error->getCode() ) {
                case 'label-too-short':
                    return new ValidationError(
repo/rest-api/src/Infrastructure/TermValidatorFactoryItemDescriptionValidator.php on lines 37..60

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

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 ( !$result->isValid() ) {
            $error = $result->getErrors()[0];
            switch ( $error->getCode() ) {
                case 'description-too-short':
                    return new ValidationError( self::CODE_EMPTY, [ self::CONTEXT_LANGUAGE => $language ] );
repo/rest-api/src/Infrastructure/TermValidatorFactoryPropertyLabelValidator.php on lines 35..58

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

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

class CreatePropertyRequest implements EditMetadataRequest {

    private array $property;
    private array $editTags;
    private bool $isBot;
repo/rest-api/src/Application/UseCases/CreateItem/CreateItemRequest.php on lines 12..47

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

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 ( !$result->isValid() ) {
            $error = $result->getErrors()[0];
            switch ( $error->getCode() ) {
                case 'label-too-short':
                    return new ValidationError( self::CODE_EMPTY, [ self::CONTEXT_LANGUAGE => $language ] );
repo/rest-api/src/Infrastructure/TermValidatorFactoryPropertyDescriptionValidator.php on lines 30..53

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

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

class CreateItemRequest implements UseCaseRequest, ItemSerializationRequest, EditMetadataRequest {

    private array $item;
    private array $editTags;
    private bool $isBot;
repo/rest-api/src/Application/UseCases/CreateProperty/CreatePropertyRequest.php on lines 10..45

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

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 ( !$result->isValid() ) {
            $error = $result->getErrors()[0];
            switch ( $error->getCode() ) {
                case 'description-too-short':
                    return new ValidationError(
repo/rest-api/src/Infrastructure/TermValidatorFactoryItemLabelValidator.php on lines 38..61

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

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

Function coalesceRuns has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function coalesceRuns( EntityId $entityId, array $changes ) {
        $coalesced = [];

        $currentRun = [];
        $currentUser = null;
Severity: Minor
Found in client/includes/Changes/ChangeRunCoalescer.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 handleRequest has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function handleRequest( $doc, WebRequest $request, OutputPage $output ) {
        // No matter what: The response is always public
        $output->getRequest()->response()->header( 'Access-Control-Allow-Origin: *' );

        $revision = 0;
Severity: Minor
Found in repo/includes/LinkedData/EntityDataRequestHandler.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 stringParse has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    protected function stringParse( $value ) {
        $date = $this->parseDate( $value );
        $precision = TimeValue::PRECISION_YEAR;
        $time = [ $this->parseFormattedNumber( $date['year'] ), 0, 0, 0, 0, 0 ];

Severity: Minor
Found in repo/includes/Parsers/DateFormatParser.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 getFormFields has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getFormFields(): array {
        $formFields = [
            self::FIELD_LANG => [
                'name' => self::FIELD_LANG,
                'class' => HTMLContentLanguageField::class,
Severity: Major
Found in repo/includes/Specials/SpecialNewItem.php - About 3 hrs to fix

    File CachingPrefetchingTermLookup.php has 301 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare( strict_types = 1 );
    
    namespace Wikibase\Lib\Store;
    Severity: Minor
    Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 3 hrs to fix

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

          private function validateAliases( AliasGroupList $aliases ): void {
              foreach ( $aliases as $aliasGroup ) {
                  $validationError = $this->aliasesInLanguageValidator->validate( $aliasGroup, "/{$aliasGroup->getLanguageCode()}" );
                  if ( $validationError ) {
                      $context = $validationError->getContext();
      repo/rest-api/src/Application/UseCases/PatchPropertyAliases/PatchedPropertyAliasesValidator.php on lines 58..76

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

      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

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

          private function validateAliases( AliasGroupList $aliases ): void {
              foreach ( $aliases as $aliasGroup ) {
                  $validationError = $this->aliasesInLanguageValidator->validate( $aliasGroup, "/{$aliasGroup->getLanguageCode()}" );
                  if ( $validationError ) {
                      $context = $validationError->getContext();
      repo/rest-api/src/Application/UseCases/PatchItemAliases/PatchedItemAliasesValidator.php on lines 58..76

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

      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

      File HtmlPageLinkRendererEndHookHandler.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      declare( strict_types = 1 );
      
      namespace Wikibase\Repo\Hooks;
      Severity: Minor
      Found in repo/includes/Hooks/HtmlPageLinkRendererEndHookHandler.php - About 3 hrs to fix

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

                _move: function ( direction, activeItem, allItems ) {
                    $.ui.suggester.prototype._move.apply( this, arguments );
                    if ( this._selectedSite === this.options.menu.getActiveItem().getSite() ) {
                        this.element.val( this._term );
                    }
        client/resources/jquery.wikibase/jquery.wikibase.siteselector.js on lines 177..182

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

        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

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

                _move: function ( direction, activeItem, allItems ) {
                    $.ui.suggester.prototype._move.apply( this, arguments );
                    if ( this._selectedSite === this.options.menu.getActiveItem().getSite() ) {
                        this.element.val( this._term );
                    }
        view/resources/jquery/wikibase/jquery.wikibase.siteselector.js on lines 174..179

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

        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

        File WikiPageEntityStore.php has 299 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace Wikibase\Repo\Store\Sql;
        
        use InvalidArgumentException;
        Severity: Minor
        Found in repo/includes/Store/Sql/WikiPageEntityStore.php - About 3 hrs to fix

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

              public function __construct(
                  EntityTitleStoreLookup $entityTitleStoreLookup,
                  ExceptionLocalizer $exceptionLocalizer,
                  PropertyDataTypeLookup $dataTypeLookup,
                  SiteLookup $siteLookup,
          Severity: Major
          Found in repo/includes/Api/ApiHelperFactory.php and 1 other location - About 3 hrs to fix
          repo/includes/ParserOutput/EntityParserOutputGeneratorFactory.php on lines 127..161

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

          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

              public function __construct(
                  DispatchingEntityViewFactory $entityViewFactory,
                  DispatchingEntityMetaTagsCreatorFactory $entityMetaTagsCreatorFactory,
                  EntityTitleLookup $entityTitleLookup,
                  LanguageFallbackChainFactory $languageFallbackChainFactory,
          repo/includes/Api/ApiHelperFactory.php on lines 128..162

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

          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

              public function __construct( Title $title, array $params = [] ) {
                  parent::__construct( 'DispatchChangeVisibilityNotification', $title, $params );
          
                  Assert::parameter( isset( $params['revisionIds'] ), '$params', '$params[\'revisionIds\'] not set.' );
                  Assert::parameter( isset( $params['visibilityChangeMap'] ), '$params', '$params[\'revisionIds\'] not set.' );
          repo/includes/ChangeModification/DispatchChangeDeletionNotificationJob.php on lines 38..48

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

          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

          Severity
          Category
          Status
          Source
          Language