wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

            [
                'wgServer', 'wgScriptPath',
                'wgPasswordSender', 'wgImageMagickConvertCommand',
                'wgLanguageCode', 'wgLocaltimezone', 'wgEnableEmail', 'wgEnableUserEmail',
                'wgDiff3', 'wgEnotifUserTalk', 'wgEnotifWatchlist', 'wgEmailAuthentication',
Severity: Major
Found in includes/installer/LocalSettingsGenerator.php and 1 other location - About 1 hr to fix
includes/libs/mime/MimeMap.php on lines 365..405

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

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

        function maybeFetch() {
            if ( typeof context.config.update.before === 'function' ) {
                context.config.update.before.call( context.data.$textbox );
            }

Severity: Minor
Found in resources/src/jquery/jquery.suggestions.js - About 1 hr to fix

    Function convertGrammar has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    mw.language.convertGrammar = function ( word, form ) {
        let grammarForms = mw.language.getData( 'os', 'grammarForms' ),
            // Ending for allative case
            endAllative = 'мæ',
            // Variable for 'j' beetwen vowels
    Severity: Minor
    Found in resources/src/mediawiki.language/languages/os.js - About 1 hr to fix

      Function Uri has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function Uri( uri, options ) {
                  let prop, hrefCur,
                      hasOptions = ( options !== undefined ),
                      defaultUri = getDefaultUri();
      
      
      Severity: Minor
      Found in resources/src/mediawiki.Uri/Uri.js - About 1 hr to fix

        Function MwWidgetsComplexNamespaceInputWidget has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            mw.widgets.ComplexNamespaceInputWidget = function MwWidgetsComplexNamespaceInputWidget( config ) {
                // Configuration initialization
                config = Object.assign(
                    {
                        // Config options for nested widgets

          Function test has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  test: function ( map, profile, exactMatchOnly ) {
                      var conditions, dir, i, op, val, j, pieceVersion, pieceVal, compare;
                      profile = $.isPlainObject( profile ) ? profile : $.client.profile();
                      if ( map.ltr && map.rtl ) {
                          dir = $( document.body ).is( '.rtl' ) ? 'rtl' : 'ltr';
          Severity: Minor
          Found in resources/lib/jquery.client/jquery.client.js - About 1 hr to fix

            Function hide$1 has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const hide$1 = function(options) {
              if (options === void 0) {
                options = {};
              }
              return {
            Severity: Minor
            Found in resources/lib/codex/codex.js - About 1 hr to fix

              Function setup has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                setup(props, { emit }) {
                  const rootElement = ref();
                  const rootClasses = computed(() => {
                    return {
                      "cdx-input-chip--disabled": props.disabled
              Severity: Minor
              Found in resources/lib/codex/codex.js - About 1 hr to fix

                Function _sfc_render$1 has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
                  const _component_cdx_label = resolveComponent("cdx-label");
                  return openBlock(), createElementBlock(
                    "span",
                    {
                Severity: Minor
                Found in resources/lib/codex/codex.js - About 1 hr to fix

                  Function _animate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      _animate: function( toShow, toHide, data ) {
                          var total, easing, duration,
                              that = this,
                              adjust = 0,
                              down = toShow.length &&
                  Severity: Minor
                  Found in resources/lib/jquery.ui/jquery.ui.accordion.js - About 1 hr to fix

                    Function _toggle has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _toggle: function( event, eventData ) {
                            var that = this,
                                toShow = eventData.newPanel,
                                toHide = eventData.oldPanel;
                    
                    
                    Severity: Minor
                    Found in resources/lib/jquery.ui/jquery.ui.tabs.js - About 1 hr to fix

                      Function _determineDate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          _determineDate: function(inst, date, defaultDate) {
                              var offsetNumeric = function(offset) {
                                  var date = new Date();
                                  date.setDate(date.getDate() + offset);
                                  return date;
                      Severity: Minor
                      Found in resources/lib/jquery.ui/jquery.ui.datepicker.js - About 1 hr to fix

                        Function push has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          Deflate.prototype.push = function (data, flush_mode) {
                            const strm = this.strm;
                            const chunkSize = this.options.chunkSize;
                            let status, _flush_mode;
                        
                        
                        Severity: Minor
                        Found in resources/lib/pako/pako_deflate.js - About 1 hr to fix

                          Function tr_static_init has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            const tr_static_init = () => {
                          
                              let n;        /* iterates over tree elements */
                              let bits;     /* bit counter */
                              let length;   /* length value */
                          Severity: Minor
                          Found in resources/lib/pako/pako_deflate.js - About 1 hr to fix

                            Method getSiteConfigSettings has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function getSiteConfigSettings(
                                    Context $context, Config $conf
                                ): array {
                                    $services = MediaWikiServices::getInstance();
                                    // Namespace related preparation
                            Severity: Minor
                            Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                              Method extractResourceLoaderModules has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function extractResourceLoaderModules( $dir, array $info ) {
                                      $defaultPaths = $info['ResourceFileModulePaths'] ?? false;
                                      if ( isset( $defaultPaths['localBasePath'] ) ) {
                                          if ( $defaultPaths['localBasePath'] === '' ) {
                                              // Avoid double slashes (e.g. /extensions/Example//path)
                              Severity: Minor
                              Found in includes/registration/ExtensionProcessor.php - About 1 hr to fix

                                Method generateUndoEditSummary has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private function generateUndoEditSummary( ?RevisionRecord $oldrev, int $undo,
                                        ?RevisionRecord $undorev, MediaWikiServices $services
                                    ) {
                                        // If we just undid one rev, use an autosummary
                                        $firstrev = $this->revisionStore->getNextRevision( $oldrev );
                                Severity: Minor
                                Found in includes/editpage/EditPage.php - About 1 hr to fix

                                  Method getFunctionStats has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function getFunctionStats() {
                                          $this->close();
                                          $cpuStats = $this->cpuProf->getLog()->aggregateByFunction();
                                          '@phan-var array $cpuStats';
                                          $realStats = $this->realProf->getLog()->aggregateByFunction();
                                  Severity: Minor
                                  Found in includes/profiler/ProfilerExcimer.php - About 1 hr to fix

                                    Method getSecondaryDataUpdates has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function getSecondaryDataUpdates( $recursive = false ) {
                                            if ( $this->isContentDeleted() ) {
                                                // This shouldn't happen, since the current content is always public,
                                                // and DataUpdates are only needed for current content.
                                                return [];
                                    Severity: Minor
                                    Found in includes/Storage/DerivedPageDataUpdater.php - About 1 hr to fix

                                      Method parse has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public static function parse( $value, $options = 0 ) {
                                              if ( $options & self::STRIP_COMMENTS ) {
                                                  $value = self::stripComments( $value );
                                              }
                                              $assoc = ( $options & self::FORCE_ASSOC ) !== 0;
                                      Severity: Minor
                                      Found in includes/json/FormatJson.php - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language