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

<?php declare( strict_types=1 );

namespace Wikibase\Repo\RestApi\Domain\ReadModel;

use Wikibase\DataModel\Term\Term;
Severity: Major
Found in repo/rest-api/src/Domain/ReadModel/Label.php and 1 other location - About 1 hr to fix
repo/rest-api/src/Domain/ReadModel/Description.php on lines 1..32

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

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 getDeletionUpdates( Title $title, $role ) {
        $updates = parent::getDeletionUpdates( $title, $role );

        $id = $this->getIdForTitle( $title );

Severity: Major
Found in repo/includes/Content/PropertyHandler.php and 1 other location - About 1 hr to fix
repo/includes/Content/ItemHandler.php on lines 195..212

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

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 getDeletionUpdates( Title $title, $role ) {
        $updates = parent::getDeletionUpdates( $title, $role );

        $id = $this->getIdForTitle( $title );

Severity: Major
Found in repo/includes/Content/ItemHandler.php and 1 other location - About 1 hr to fix
repo/includes/Content/PropertyHandler.php on lines 175..192

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

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

<?php declare( strict_types=1 );

namespace Wikibase\Repo\RestApi\Domain\ReadModel;

use Wikibase\DataModel\Term\Term;
Severity: Major
Found in repo/rest-api/src/Domain/ReadModel/Description.php and 1 other location - About 1 hr to fix
repo/rest-api/src/Domain/ReadModel/Label.php on lines 1..32

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

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

    function attachCopyrightTooltip( $entityview, viewName ) {
        var startEditingEvents = [
            'entitytermsviewafterstartediting',
            'sitelinkgroupviewafterstartediting',
            'statementviewafterstartediting'
Severity: Minor
Found in repo/resources/wikibase.ui.entityViewInit.js - About 1 hr to fix

    Function value has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            value: function ( value ) {
                if ( value !== undefined ) {
                    return this.option( 'value', value );
                }
    
    

      Function stopEditing has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          SELF.prototype.stopEditing = function ( dropValue ) {
              if ( !dropValue && !this._viewHasSavableValue() ) {
                  return;
              }
      
      
      Severity: Minor
      Found in view/resources/wikibase/view/ToolbarViewController.js - About 1 hr to fix

        Function _createHelperTag has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                _createHelperTag: function () {
                    var $tag = this.createTag( '', '', true ),
                        input = $tag.find( 'input' );
        
                    // Add placeholder and auto-expand afterwards:
        Severity: Minor
        Found in view/resources/jquery/ui/jquery.ui.tagadata.js - About 1 hr to fix

          Method getSiteLinkAddRemoveParams has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getSiteLinkAddRemoveParams( DiffOp $diffOp, $action, $siteId, Title $title = null ) {
                  $params = [];
          
                  if ( in_array( $action, [ 'remove', 'restore' ] ) ) {
                      // Messages: wikibase-comment-remove, wikibase-comment-restore
          Severity: Minor
          Found in client/includes/RecentChanges/SiteLinkCommentCreator.php - About 1 hr to fix

            Function commit has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Store.prototype.commit = function commit (_type, _payload, _options) {
                var this$1$1 = this;
            
              // check object-style commit
              var ref = unifyObjectStyle(_type, _payload, _options);
            Severity: Minor
            Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

              Method getRecentChangeId has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getRecentChangeId( RecentChange $change ) {
                      $attribs = $change->getAttributes();
              
                      //XXX: need to check master?
                      $db = $this->connectionManager->getReadConnection();
              Severity: Minor
              Found in client/includes/RecentChanges/RecentChangesFinder.php - About 1 hr to fix

                Function ddb0 has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                /***/ (function(module, exports, __webpack_require__) {
                
                var global = __webpack_require__("da84");
                var DOMIterables = __webpack_require__("fdbc");
                var ArrayIteratorMethods = __webpack_require__("e260");
                Severity: Minor
                Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

                  Function main has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  async function main() {
                      const client = new ApolloClient( {
                          uri: 'https://api.github.com/graphql',
                          request: ( operation ) => {
                              operation.setContext( {
                  Severity: Minor
                  Found in build/dist-size/analyze/index.js - About 1 hr to fix

                    Function buildSizeDeltaAnnotation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function buildSizeDeltaAnnotation( revision ) {
                        if ( revision[ CUSTOM_FIELDS.PREVIOUS_SIZE ] === null || revision[ FIELDS.SIZE ] === null ) {
                            // inception & removal may be a notable but not with respect to size
                            return null;
                        }
                    Severity: Minor
                    Found in build/dist-size/web/lib/main.js - About 1 hr to fix

                      Method newRendererFromParser has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function newRendererFromParser(
                              Parser $parser,
                              string $type = DataAccessSnakFormatterFactory::TYPE_ESCAPED_PLAINTEXT
                          ): StatementGroupRenderer {
                              $usageAccumulator = $this->usageAccumulatorFactory->newFromParser( $parser );

                        Method getSecondaryLinks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getSecondaryLinks() {
                                $ret = [];
                        
                                if ( $this->getBundleCount( true, [ $this, 'callbackForBundleCount' ] ) === 1 ) {
                                    $ret[] = $this->getAgentLink();
                        Severity: Minor
                        Found in client/includes/Notifications/PageConnectionPresentationModel.php - About 1 hr to fix

                          Method fetchIds has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function fetchIds( $limit ) {
                                  Assert::parameter( is_int( $limit ) && $limit > 0, '$limit', '$limit must be a positive integer' );
                          
                                  $dbr = $this->db->connections()->getReadConnection();
                                  $queryBuilder = $dbr->newSelectQueryBuilder();
                          Severity: Minor
                          Found in repo/includes/Store/Sql/SqlEntityIdPager.php - About 1 hr to fix

                            Method execute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function execute( $subPage ) {
                                    parent::execute( $subPage );
                            
                                    $this->checkPermissions();
                                    $this->checkBlocked();
                            Severity: Minor
                            Found in repo/includes/Specials/SpecialMergeItems.php - About 1 hr to fix

                              Method applyChangeOp has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function applyChangeOp( ChangeOp $changeOp, EntityDocument $entity, Summary $summary = null ): ChangeOpResult {
                                      try {
                                          // NOTE: Always validate modification against the current revision, if it exists!
                                          //       Otherwise, we may miss e.g. a combination of language/label/description
                                          //       that was already taken.
                              Severity: Minor
                              Found in repo/includes/Api/ModifyEntity.php - About 1 hr to fix

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

                                    protected function getAllowedParams(): array {
                                        return [
                                            'generate' => [
                                                ParamValidator::PARAM_TYPE => [
                                                    SnakFormatter::FORMAT_PLAIN,
                                Severity: Minor
                                Found in repo/includes/Api/FormatSnakValue.php - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language