wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Method newImplementation has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function newImplementation(): WikibaseLuaEntityBindings {
        $lang = $this->getLanguage();
        $snakFormatterFactory = WikibaseClient::getDataAccessSnakFormatterFactory();
        $plainTextSnakFormatter = $snakFormatterFactory->newWikitextSnakFormatter(
            $lang,
Severity: Minor
Found in client/includes/DataAccess/Scribunto/WikibaseEntityLibrary.php - About 1 hr to fix

    Method injectRCRecords has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function injectRCRecords( array $titles, EntityChange $change, array $rootJobParams = [] ) {
            if ( $titles === [] ) {
                return;
            }
    
    
    Severity: Minor
    Found in client/includes/Changes/WikiPageUpdater.php - About 1 hr to fix

      Method getArchiveRows has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getArchiveRows( int &$processed, int &$staleRecords, string $entityIdSerialization ): array {
              $dbr = $this->db->connections()->getReadConnection();
      
              $iterator = new BatchRowIterator(
                  $dbr,

        Method getConflictsForItem has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getConflictsForItem( ItemId $itemId, SiteLinkList $siteLinkList, int $db = null ) {
                if ( $siteLinkList->isEmpty() ) {
                    return [];
                }
        
        
        Severity: Minor
        Found in repo/includes/Store/Sql/SqlSiteLinkConflictLookup.php - About 1 hr to fix

          Method addMainSnak has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function addMainSnak( EntityId $entityId, $statementLName, Statement $statement, $isBest ) {
                  $snak = $statement->getMainSnak();
          
                  $entityLName = $this->vocabulary->getEntityLName( $entityId );
                  $entityRepository = $this->vocabulary->getEntityRepositoryName( $entityId );
          Severity: Minor
          Found in repo/includes/Rdf/FullStatementRdfBuilder.php - About 1 hr to fix

            Method getDataUpdaters has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getDataUpdaters(): array {
                    $propertyDataTypeMatcher = new PropertyDataTypeMatcher( $this->propertyDataTypeLookup );
            
                    $statementUpdater = new CompositeStatementDataUpdater(
                        new ExternalLinksDataUpdater( $propertyDataTypeMatcher ),
            Severity: Minor
            Found in repo/includes/ParserOutput/EntityParserOutputGeneratorFactory.php - About 1 hr to fix

              Method stringParse has 40 lines of code (exceeds 25 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 1 hr to fix

                Method getSnakFormatter has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getSnakFormatter( $format, FormatterOptions $options ) {
                        $options->defaultOption( SnakFormatter::OPT_ON_ERROR, SnakFormatter::ON_ERROR_WARN );
                
                        $this->valueFormatterFactory->applyLanguageDefaults( $options );
                        $lang = $options->getOption( ValueFormatter::OPT_LANG );
                Severity: Minor
                Found in lib/includes/Formatters/OutputFormatSnakFormatterFactory.php - About 1 hr to fix

                  Function formatSnak has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function formatSnak( Snak $snak ) {
                          if ( $snak instanceof PropertyValueSnak ) {
                              $value = $snak->getDataValue();
                  
                              // FIXME: All usage tracking is technically misplaced here, as it repeats knowledge from
                  Severity: Minor
                  Found in client/includes/Usage/UsageTrackingSnakFormatter.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 dumpEntities has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function dumpEntities( array $entityIds, int &$dumpCount ): void {
                          $toLoad = [];
                          foreach ( $entityIds as $entityId ) {
                              if ( $this->idMatchesFilters( $entityId ) ) {
                                  $toLoad[] = $entityId;
                  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 getChangeOps has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getChangeOps( Fingerprint $fingerprint ) {
                          $changeOpFactory = $this->changeOpFactory;
                          $changeOps = [];
                  
                          if ( $this->label !== '' ) {
                  Severity: Minor
                  Found in repo/includes/Specials/SpecialSetLabelDescriptionAliases.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 formatArg has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function formatArg( $arg ) {
                          try {
                              if ( $arg instanceof Snak ) {
                                  return $this->snakFormatter->formatSnak( $arg );
                              } elseif ( $arg instanceof EntityId ) {
                  Severity: Minor
                  Found in repo/includes/SummaryFormatter.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 internalDoHtmlPageLinkRendererEnd has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function internalDoHtmlPageLinkRendererEnd(
                          LinkRenderer $linkRenderer,
                          Title $target,
                          &$text,
                          array &$customAttribs,
                  Severity: Minor
                  Found in repo/includes/Hooks/HtmlPageLinkRendererEndHookHandler.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 addStatement has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function addStatement( EntityId $entityId, Statement $statement, $isBest ) {
                          $statementLName = $this->vocabulary->getStatementLName( $statement );
                  
                          $entityRepository = $this->vocabulary->getEntityRepositoryName( $entityId );
                  
                  
                  Severity: Minor
                  Found in repo/includes/Rdf/FullStatementRdfBuilder.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 buildIndexedAliasesChangeOps has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function buildIndexedAliasesChangeOps( array $indexedAliases ) {
                          $aliasesChangeOps = new ChangeOps();
                  
                          foreach ( $indexedAliases as $langCode => $serializations ) {
                              $aliasesToSet = [];

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

                      public function getEntityRevision(
                          EntityId $entityId,
                          $revisionId = 0,
                          $mode = LookupConstants::LATEST_FROM_REPLICA
                      ) {
                  Severity: Minor
                  Found in lib/includes/Store/Sql/WikiPageEntityRevisionLookup.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 __construct has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __construct( iterable $snaks, array $certainPropertyIds ) {
                          foreach ( $certainPropertyIds as $certainPropertyId ) {
                              /** @var PropertyId $certainPropertyId */
                              '@phan-var PropertyId $certainPropertyId';
                              if ( $certainPropertyId !== null ) {
                  Severity: Minor
                  Found in lib/includes/Formatters/Reference/ByCertainPropertyIdGrouper.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 prefetchTerms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function prefetchTerms(
                          array $entityIds,
                          array $termTypes,
                          array $languageCodes
                      ) {
                  Severity: Minor
                  Found in lib/includes/Store/Sql/Terms/PrefetchingEntityTermLookupBase.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

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

                      public function getParamSettings(): array {
                          return [
                              self::ITEM_ID_PATH_PARAM => [
                                  self::PARAM_SOURCE => 'path',
                                  ParamValidator::PARAM_TYPE => 'string',
                  Severity: Major
                  Found in repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php and 1 other location - About 1 hr to fix
                  repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php on lines 112..127

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

                  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

                      protected function renderLabelValuePair( $fieldName, $valueHtml ) {
                          $html = Html::openElement( 'tr' );
                  
                          $html .= Html::element( 'th', [ 'class' => 'wb-globe-' . $fieldName ],
                              $this->getFieldLabel( $fieldName )->text() );
                  Severity: Major
                  Found in lib/includes/Formatters/GlobeCoordinateDetailsFormatter.php and 1 other location - About 1 hr to fix
                  lib/includes/Formatters/QuantityDetailsFormatter.php on lines 157..167

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

                  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