wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Function 7c73 has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

/***/ (function(module, exports, __webpack_require__) {

var anObject = __webpack_require__("825a");
var defineProperties = __webpack_require__("37e8");
var enumBugKeys = __webpack_require__("7839");
Severity: Major
Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 2 hrs to fix

    Method validateFormData has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function validateFormData( array $formData ) {
            $status = Status::newGood();
    
            if ( $formData[ self::FIELD_LABEL ] == ''
                 && $formData[ self::FIELD_DESCRIPTION ] == ''
    Severity: Major
    Found in repo/includes/Specials/SpecialNewProperty.php - About 2 hrs to fix

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

          private function newSuccessHttpResponse( GetSitelinkResponse $useCaseResponse ): Response {
              $httpResponse = $this->getResponseFactory()->create();
              $httpResponse->setHeader( 'Content-Type', 'application/json' );
              $httpResponse->setHeader( 'Last-Modified', wfTimestamp( TS_RFC2822, $useCaseResponse->getLastModified() ) );
              $this->setEtagFromRevId( $httpResponse, $useCaseResponse->getRevisionId() );
      Severity: Major
      Found in repo/rest-api/src/RouteHandlers/GetSitelinkRouteHandler.php and 3 other locations - About 2 hrs to fix
      repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php on lines 104..114
      repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php on lines 94..106
      repo/rest-api/src/RouteHandlers/GetSitelinksRouteHandler.php on lines 102..112

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

      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

          private function newSuccessHttpResponse( GetPropertyResponse $useCaseResponse ): Response {
              $httpResponse = $this->getResponseFactory()->create();
              $httpResponse->setHeader( 'Content-Type', 'application/json' );
              $httpResponse->setHeader( 'Last-Modified', wfTimestamp( TS_RFC2822, $useCaseResponse->getLastModified() ) );
              $this->setEtagFromRevId( $httpResponse, $useCaseResponse->getRevisionId() );
      Severity: Major
      Found in repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php and 3 other locations - About 2 hrs to fix
      repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php on lines 104..114
      repo/rest-api/src/RouteHandlers/GetSitelinkRouteHandler.php on lines 106..119
      repo/rest-api/src/RouteHandlers/GetSitelinksRouteHandler.php on lines 102..112

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

      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

          private function newSuccessHttpResponse( GetItemResponse $useCaseResponse ): Response {
              $httpResponse = $this->getResponseFactory()->create();
              $httpResponse->setHeader( 'Content-Type', 'application/json' );
              $httpResponse->setHeader( 'Last-Modified', wfTimestamp( TS_RFC2822, $useCaseResponse->getLastModified() ) );
              $this->setEtagFromRevId( $httpResponse, $useCaseResponse->getRevisionId() );
      Severity: Major
      Found in repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php and 3 other locations - About 2 hrs to fix
      repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php on lines 94..106
      repo/rest-api/src/RouteHandlers/GetSitelinkRouteHandler.php on lines 106..119
      repo/rest-api/src/RouteHandlers/GetSitelinksRouteHandler.php on lines 102..112

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

      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

          private function newSuccessHttpResponse( GetSitelinksResponse $useCaseResponse ): Response {
              $httpResponse = $this->getResponseFactory()->create();
              $httpResponse->setHeader( 'Content-Type', 'application/json' );
              $httpResponse->setHeader( 'Last-Modified', wfTimestamp( TS_RFC2822, $useCaseResponse->getLastModified() ) );
              $this->setEtagFromRevId( $httpResponse, $useCaseResponse->getRevisionId() );
      repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php on lines 104..114
      repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php on lines 94..106
      repo/rest-api/src/RouteHandlers/GetSitelinkRouteHandler.php on lines 106..119

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

      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

      SqlStore has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SqlStore implements Store {
      
          /**
           * @var EntityChangeFactory
           */
      Severity: Minor
      Found in repo/includes/Store/Sql/SqlStore.php - About 2 hrs to fix

        SpecialSetLabelDescriptionAliases has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class SpecialSetLabelDescriptionAliases extends SpecialModifyEntity {
        
            use ParameterizedDescriptionTrait;
        
            public const BUTTON_MESSAGE_PUBLISH = 'publishchanges';
        Severity: Minor
        Found in repo/includes/Specials/SpecialSetLabelDescriptionAliases.php - About 2 hrs to fix

          DeserializedRequestAdapter has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class DeserializedRequestAdapter implements
              DeserializedAddItemStatementRequest,
              DeserializedAddPropertyStatementRequest,
              DeserializedGetItemRequest,
              DeserializedGetSitelinksRequest,

            DataTypeDefinitions has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class DataTypeDefinitions {
            
                /**
                 * Constant for indicating that callback maps should be returned with the "VT:" and "PT:"
                 * prefixes in the array keys indicating whether the callback applies to a value type or a
            Severity: Minor
            Found in lib/includes/DataTypeDefinitions.php - About 2 hrs to fix

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

              module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
                createIteratorConstructor(IteratorConstructor, NAME, next);
              
                var getIterationMethod = function (KIND) {
                  if (KIND === DEFAULT && defaultIterator) return defaultIterator;
              Severity: Major
              Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 2 hrs to fix

                Method acquireAndInsertTerms has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function acquireAndInsertTerms( Int32EntityId $entityId, Fingerprint $fingerprint ): array {
                        $entityNumericId = $entityId->getNumericId();
                
                        $dbw = $this->getDbw();
                        $queryBuilder = $dbw->newSelectQueryBuilder()
                Severity: Major
                Found in lib/includes/Store/Sql/Terms/DatabaseTermStoreWriterBase.php - About 2 hrs to fix

                  Method getTermMatchQueries has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function getTermMatchQueries(
                          IReadableDatabase $dbr,
                          TermIndexSearchCriteria $mask,
                          string $entityType,
                          $termType = null,
                  Severity: Major
                  Found in lib/includes/Store/Sql/Terms/DatabaseMatchingTermsLookup.php - About 2 hrs to fix

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

                        var Item = function ( label, value, site ) {
                            if ( !label || !value || !site ) {
                                throw new Error( 'Required parameter(s) not specified' );
                            }
                    
                    
                    client/resources/jquery.wikibase/jquery.wikibase.siteselector.js on lines 338..347

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

                    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

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

                            _grepSubDomainFromTerm: function () {
                                // Extract either a subdomain (the word after "//") or simply the first word.
                                var matches = /\/\/(\w[\w-]+)/.exec( this._term )
                                    || /(\w[\w-]+)/.exec( this._term );
                    
                    
                    view/resources/jquery/wikibase/jquery.wikibase.siteselector.js on lines 266..272

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

                    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

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

                        var Item = function ( label, value, site ) {
                                if ( !label || !value || !site ) {
                                    throw new Error( 'Required parameter(s) not specified' );
                                }
                    
                    
                    view/resources/jquery/wikibase/jquery.wikibase.siteselector.js on lines 344..352

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

                    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

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

                            _grepSubDomainFromTerm: function () {
                                // Extract either a subdomain (the word after "//") or simply the first word.
                                var matches = /\/\/(\w[\w-]+)/.exec( this._term )
                                    || /(\w[\w-]+)/.exec( this._term );
                    
                    
                    client/resources/jquery.wikibase/jquery.wikibase.siteselector.js on lines 269..275

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

                    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

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

                            EntityIdFormatterFactory $htmlIdFormatterFactory,
                            EntityIdFormatterFactory $plainTextIdFormatterFactory,
                            HtmlSnakFormatterFactory $htmlSnakFormatterFactory,
                            StatementGrouper $statementGrouper,
                            PropertyOrderProvider $propertyOrderProvider,
                    Severity: Major
                    Found in view/src/ViewFactory.php - About 2 hrs to fix

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

                              FormatterLabelDescriptionLookupFactory $labelDescriptionLookupFactory,
                              LanguageNameLookupFactory $languageNameLookupFactory,
                              EntityIdParser $itemUriParser,
                              string $geoShapeStorageBaseUrl,
                              string $tabularDataStorageBaseUrl,
                      Severity: Major
                      Found in lib/includes/Formatters/WikibaseValueFormatterBuilders.php - About 2 hrs to fix

                        File jquery.wikibase.edittoolbar.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        /**
                         * @license GPL-2.0-or-later
                         * @author H. Snater < mediawiki@snater.com >
                         */
                        ( function ( wb ) {
                        Severity: Minor
                        Found in view/resources/jquery/wikibase/toolbar/jquery.wikibase.edittoolbar.js - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language