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

        getClaimRevision: function ( statementGuid ) {
            if ( Object.prototype.hasOwnProperty.call( this._revisions.claimRevisions, statementGuid ) ) {
                return this._revisions.claimRevisions[ statementGuid ];
            }

Severity: Major
Found in view/resources/wikibase/wikibase.RevisionStore.js and 1 other location - About 1 hr to fix
view/resources/wikibase/wikibase.RevisionStore.js on lines 79..85

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

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

        getSitelinksRevision: function ( siteId ) {
            if ( Object.prototype.hasOwnProperty.call( this._revisions.sitelinksRevision, siteId ) ) {
                return this._revisions.sitelinksRevision[ siteId ];
            }

Severity: Major
Found in view/resources/wikibase/wikibase.RevisionStore.js and 1 other location - About 1 hr to fix
view/resources/wikibase/wikibase.RevisionStore.js on lines 97..103

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

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 _initDefaultSource has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _initDefaultSource: function () {
            var self = this;

            return function ( term ) {
                var deferred = $.Deferred(),
Severity: Minor
Found in view/resources/jquery/wikibase/jquery.wikibase.entityselector.js - About 1 hr to fix

    Function exports has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function ( grunt ) {
        grunt.loadNpmTasks( 'grunt-eslint' );
        grunt.loadNpmTasks( 'grunt-banana-checker' );
        grunt.loadNpmTasks( 'grunt-stylelint' );
    
    
    Severity: Minor
    Found in Gruntfile.js - About 1 hr to fix

      Function highlightSubstring has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var highlightSubstring = function ( substring, string, options ) {
              if ( substring === '' || string === '' ) {
                  return string;
              }
      
      
      Severity: Minor
      Found in client/resources/util.highlightSubstring.js - About 1 hr to fix

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

            public function getAllowedParams(): array {
                return [
                    'prop' => [
                        ParamValidator::PARAM_ISMULTI => true,
                        ParamValidator::PARAM_TYPE => [
        Severity: Minor
        Found in client/includes/Api/ApiListEntityUsage.php - About 1 hr to fix

          Function createLogger has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createLogger (ref) {
            if ( ref === void 0 ) ref = {};
            var collapsed = ref.collapsed; if ( collapsed === void 0 ) collapsed = true;
            var filter = ref.filter; if ( filter === void 0 ) filter = function (mutation, stateBefore, stateAfter) { return true; };
            var transformer = ref.transformer; if ( transformer === void 0 ) transformer = function (state) { return state; };
          Severity: Minor
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

            Method saveEntityContent has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function saveEntityContent(
                    EntityContent $entityContent,
                    User $user,
                    $summary = '',
                    $flags = 0,
            Severity: Minor
            Found in repo/includes/Store/Sql/WikiPageEntityStore.php - About 1 hr to fix

              Method getExamplesMessages has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function getExamplesMessages(): array {
                      $id = $this->sandboxEntityIds[ 'mainItem' ];
              
                      return [
                          // Creating new entities
              Severity: Minor
              Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

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

                    protected function getAllowedParams(): array {
                        $siteIds = $this->siteLinkGlobalIdentifiersProvider->getList( $this->siteLinkGroups );
                
                        return array_merge( parent::getAllowedParams(), [
                            'ids' => [
                Severity: Minor
                Found in repo/includes/Api/GetEntities.php - About 1 hr to fix

                  Method updateQuantityUnit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function updateQuantityUnit( EntityDocument $entity ) {
                          $updateCounter = 0;
                  
                          if ( !$entity instanceof StatementListProvider ) {
                              $this->errorReporter->reportMessage(
                  Severity: Minor
                  Found in repo/maintenance/EntityQuantityUnitRebuilder.php - About 1 hr to fix

                    Method validateAndDeserialize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function validateAndDeserialize( PropertyLabelEditRequest $request ): Term {
                            $property = $this->propertyRetriever->getPropertyWriteModel( new NumericPropertyId( $request->getPropertyId() ) );
                            $label = $request->getLabel();
                            $language = $request->getLanguageCode();
                    
                    

                      Method getLinks has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getLinks(
                              ?array $numericIds = null,
                              ?array $siteIds = null,
                              ?array $pageNames = null
                          ): array {
                      Severity: Minor
                      Found in lib/includes/Store/Sql/SiteLinkTable.php - About 1 hr to fix

                        Method formatReference has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function formatReference( Reference $reference ): string {
                                $referenceSnaks = new ByCertainPropertyIdGrouper( $reference->getSnaks(), [
                                    $this->properties->referenceUrlPropertyId,
                                    $this->properties->titlePropertyId,
                                    $this->properties->statedInPropertyId,
                        Severity: Minor
                        Found in lib/includes/Formatters/Reference/DataBridgeReferenceFormatter.php - About 1 hr to fix

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

                              public function __construct(
                                  LabelsSyntaxValidator $labelsSyntaxValidator,
                                  ItemLabelsContentsValidator $labelsContentsValidator,
                                  DescriptionsSyntaxValidator $descriptionsSyntaxValidator,
                                  ItemDescriptionsContentsValidator $descriptionsContentsValidator,
                          Severity: Major
                          Found in repo/rest-api/src/Application/Validation/ItemValidator.php and 3 other locations - About 1 hr to fix
                          client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.php on lines 63..79
                          client/includes/Hooks/OtherProjectsSidebarGeneratorFactory.php on lines 54..70
                          repo/rest-api/src/Application/UseCases/PatchItem/PatchedItemValidator.php on lines 49..65

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

                          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 4 locations. Consider refactoring.
                          Open

                              public function __construct(
                                  TermFallbackCacheFacade $termFallbackCacheFacade,
                                  RedirectResolvingLatestRevisionLookup $redirectResolvingLatestRevisionLookup,
                                  LanguageFallbackChainFactory $languageFallbackChainFactory,
                                  TermLookup $termLookup,
                          client/includes/Hooks/OtherProjectsSidebarGeneratorFactory.php on lines 54..70
                          repo/rest-api/src/Application/UseCases/PatchItem/PatchedItemValidator.php on lines 49..65
                          repo/rest-api/src/Application/Validation/ItemValidator.php on lines 28..44

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

                          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 4 locations. Consider refactoring.
                          Open

                              public function __construct(
                                  LabelsSyntaxValidator $labelsSyntaxValidator,
                                  ItemLabelsContentsValidator $labelsContentsValidator,
                                  DescriptionsSyntaxValidator $descriptionsSyntaxValidator,
                                  ItemDescriptionsContentsValidator $descriptionsContentsValidator,
                          client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.php on lines 63..79
                          client/includes/Hooks/OtherProjectsSidebarGeneratorFactory.php on lines 54..70
                          repo/rest-api/src/Application/Validation/ItemValidator.php on lines 28..44

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

                          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 4 locations. Consider refactoring.
                          Open

                              public function __construct(
                                  SettingsArray $settings,
                                  SiteLinkLookup $siteLinkLookup,
                                  SiteLookup $siteLookup,
                                  EntityLookup $entityLookup,
                          client/includes/DataAccess/Scribunto/CachingFallbackBasedTermLookup.php on lines 63..79
                          repo/rest-api/src/Application/UseCases/PatchItem/PatchedItemValidator.php on lines 49..65
                          repo/rest-api/src/Application/Validation/ItemValidator.php on lines 28..44

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

                          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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function run(): bool {
                                  $change = $this->getChange();
                                  $titles = $this->getTitles();
                          
                                  if ( !$change || $titles === [] ) {
                          Severity: Minor
                          Found in client/includes/Changes/InjectRCRecordsJob.php - About 1 hr 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 getMediaWikiPermissionsToCheck has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function getMediaWikiPermissionsToCheck( $action, $entityType ) {
                                  if ( $action === self::ACTION_MW_CREATE ) {
                                      $entityTypeSpecificCreatePermission = $entityType . '-create';
                          
                                      $permissions = [ 'read', 'edit', 'createpage' ];
                          Severity: Minor
                          Found in repo/includes/Store/WikiPageEntityStorePermissionChecker.php - About 1 hr 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