wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

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

      Function getEntityTermsView has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          SELF.prototype.getEntityTermsView = function ( startEditingCallback, value, $entitytermsview ) {
              var controller;
              var startEditingController = function () {
                  return controller.startEditing();
              };
      Severity: Minor
      Found in view/resources/wikibase/view/ControllerViewFactory.js - About 1 hr to fix

        Function plot has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function plot( el, historyData ) {
            const traces = [];
            const annotations = [];
        
            for ( const fileName in historyData ) {
        Severity: Minor
        Found in build/dist-size/web/lib/main.js - About 1 hr to fix

          Function installModule has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function installModule (store, rootState, path, module, hot) {
            var isRoot = !path.length;
            var namespace = store._modules.getNamespace(path);
          
            // register in namespace map
          Severity: Minor
          Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

            Method getRankedSearchResults has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getRankedSearchResults(
                    $text,
                    $languageCode,
                    $entityType,
                    $limit,
            Severity: Minor
            Found in repo/includes/FederatedProperties/ApiEntitySearchHelper.php - About 1 hr to fix

              Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function run(): bool {
                      // TODO: for v2 of this job, we could actually get all the newest revision from the DB,
                      //       calculate the change_info ourselves and thus make wb_changes table obsolete?
              
                      $repoSettings = WikibaseRepo::getSettings();
              Severity: Minor
              Found in repo/includes/ChangeModification/DispatchChangesJob.php - About 1 hr to fix

                Method getMediaWikiPermissionsToCheck has 39 lines of code (exceeds 25 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

                  Method executeInternal has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function executeInternal(): void {
                          $params = $this->extractRequestParams();
                          $statement = $this->getStatementFromParams( $params );
                          $guid = $statement->getGuid();
                  
                  
                  Severity: Minor
                  Found in repo/includes/Api/SetClaim.php - About 1 hr to fix

                    Method validate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function validate( $value ): Result {
                            if ( !is_string( $value ) ) {
                                throw new InvalidArgumentException( 'Expected a string' );
                            }
                    
                    
                    Severity: Minor
                    Found in repo/includes/Validators/EntityUriValidator.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language