wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Function generateDump has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateDump( EntityIdPager $idPager ): void {
        $dumpCount = 0;

        $this->preDump();

Severity: Minor
Found in repo/includes/Dumpers/DumpGenerator.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 getTermsSerializationWithFallbackInfo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTermsSerializationWithFallbackInfo(
        array $serialization,
        array $termFallbackChains
    ) {
        $newSerialization = $serialization;
Severity: Minor
Found in repo/includes/Api/ResultBuilder.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

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

        ApiMain $mainModule,
        string $moduleName,
        StringNormalizer $stringNormalizer,
        LanguageFallbackChainFactory $languageFallbackChainFactory,
        SiteLinkGlobalIdentifiersProvider $siteLinkGlobalIdentifiersProvider,
Severity: Major
Found in repo/includes/Api/GetEntities.php - About 1 hr to fix

    Function collectNewAndOldTerms has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private function collectNewAndOldTerms( ChangeOpFingerprintResult $changeOpsResult ): array {
            $traversable = $this->makeRecursiveTraversable( $changeOpsResult );
    
            $newTerms = [];
            $oldTerms = [];
    Severity: Minor
    Found in repo/includes/Validators/FingerprintUniquenessValidator.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

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

            EntityDataUriManager $uriManager,
            HTMLCacheUpdater $htmlCacheUpdater,
            EntityIdParser $entityIdParser,
            EntityRevisionLookup $entityRevisionLookup,
            EntityRedirectLookup $entityRedirectLookup,
    Severity: Major
    Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 1 hr to fix

      Function next has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function next() {
              $id = null;
      
              while ( $id === null ) {
                  $this->reader->next();
      Severity: Minor
      Found in repo/includes/IO/EntityIdReader.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 cleanupGregorianValue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function cleanupGregorianValue( $dateValue, $precision ) {
              try {
                  [ $minus, $y, $m, $d, $time ] = $this->parseDateValue( $dateValue );
              } catch ( IllegalValueException $e ) {
                  return null;
      Severity: Minor
      Found in repo/includes/Rdf/DateTimeValueCleaner.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

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

              Language $contentLanguage,
              HttpRequestFactory $httpRequestFactory,
              IBufferingStatsdDataFactory $statsdDataFactory,
              UserOptionsLookup $userOptionsLookup,
              EntityContentFactory $entityContentFactory,
      Severity: Major
      Found in repo/includes/Hooks/OutputPageBeforeHTMLHookHandler.php - About 1 hr to fix

        Function addSiteLinks has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function addSiteLinks( Item $item ) {
                $id = $item->getId();
                $entityLName = $this->vocabulary->getEntityLName( $id );
                $entityRepoName = $this->vocabulary->getEntityRepositoryName( $id );
        
        
        Severity: Minor
        Found in repo/includes/Rdf/SiteLinksRdfBuilder.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 equals has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function equals( Content $that = null ) {
                if ( $that === $this ) {
                    return true;
                }
        
        
        Severity: Minor
        Found in repo/includes/Content/EntityContent.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 execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute() {
                if ( !WikibaseSettings::isRepoEnabled() ) {
                    $this->fatalError( "You need to have Wikibase enabled in order to use this maintenance script!" );
                }
                $format = $this->getOption( 'format', 'json' );
        Severity: Minor
        Found in repo/maintenance/updateUnits.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 getTermMatchQueries has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getTermMatchQueries(
                IReadableDatabase $dbr,
                TermIndexSearchCriteria $mask,
                string $entityType,
                $termType = null,
        Severity: Minor
        Found in lib/includes/Store/Sql/Terms/DatabaseMatchingTermsLookup.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 assertConfigArrayWellFormed has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function assertConfigArrayWellFormed( array $sourceConfig ) {
                Assert::parameterElementType( 'array', $sourceConfig, '$sourceConfig' );
        
                foreach ( $sourceConfig as $sourceName => $sourceData ) {
                    if ( !is_string( $sourceName ) ) {
        Severity: Minor
        Found in data-access/src/EntitySourceDefinitionsConfigParser.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

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

                EntityIdParser $entityIdParser,
                EntityIdComposer $entityIdComposer,
                Deserializer $dataValueDeserializer,
                NameTableStore $slotRoleStore,
                DataAccessSettings $dataAccessSettings,
        Severity: Major
        Found in data-access/src/SingleEntitySourceServices.php - About 1 hr to fix

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

              public async trackSavingErrorsFallingBackToGenericView(): Promise<void> {
                  for ( const error of this.state.applicationErrors ) {
                      this.store.$services.get( 'tracker' ).trackSavingUnknownError( error.type );
                  }
              }
          Severity: Major
          Found in client/data-bridge/src/store/actions.ts and 1 other location - About 1 hr to fix
          client/data-bridge/src/store/actions.ts on lines 374..378

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

          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 async trackErrorsFallingBackToGenericView(): Promise<void> {
                  for ( const error of this.state.applicationErrors ) {
                      this.store.$services.get( 'tracker' ).trackUnknownError( error.type );
                  }
              }
          Severity: Major
          Found in client/data-bridge/src/store/actions.ts and 1 other location - About 1 hr to fix
          client/data-bridge/src/store/actions.ts on lines 380..384

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

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

                  show: function () {
                      var self = this;
          
                      // eslint-disable-next-line no-jquery/no-sizzle
                      if ( this._tipsy.$tip && this._tipsy.$tip.is( ':visible' ) ) {
          Severity: Minor
          Found in client/resources/jquery.wikibase/jquery.wikibase.wbtooltip.js - About 1 hr to fix

            Function show has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    show: function () {
                        var self = this;
            
                        // eslint-disable-next-line no-jquery/no-sizzle
                        if ( this._tipsy.$tip && this._tipsy.$tip.is( ':visible' ) ) {
            Severity: Minor
            Found in view/resources/jquery/wikibase/jquery.wikibase.wbtooltip.js - About 1 hr to fix

              Function _create has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      _create: function () {
                          var self = this,
                              widgetName = this.widgetName,
                              $menu = this._buildMenu().appendTo( document.body ).hide();
              
              

                Method getRevisionHeader has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getRevisionHeader( RevisionRecord $rev, $complete = '' ) {
                        //NOTE: This must be kept in sync with the parent implementation.
                        //      Perhaps some parts could be factored out to reduce code duplication.
                
                        $lang = $this->getLanguage();
                Severity: Minor
                Found in repo/includes/Diff/EntityContentDiffView.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language