rilwis/meta-box

View on GitHub
js/media.js

Summary

Maintainability
D
3 days
Test Coverage

File media.js has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function ( $, wp, _, rwmb, i18n ) {
    'use strict';

    var views = rwmb.views = rwmb.views || {},
        models = rwmb.models = rwmb.models || {},
Severity: Minor
Found in js/media.js - About 6 hrs to fix

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

            switchItem: function ( item ) {
                if ( this._switchFrame ) {
                    this._switchFrame.dispose();
                }
                this._switchFrame = new MediaSelect( {
    Severity: Minor
    Found in js/media.js - About 1 hr to fix

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

              initialize: function ( options ) {
                  var that = this,
                      fieldName = options.input.name;
                  this.$input = $( options.input );
      
      
      Severity: Minor
      Found in js/media.js - About 1 hr to fix

        Function click .button has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    'click .button': function () {
                        if ( this._frame ) {
                            this._frame.dispose();
                        }
                        var maxFiles = this.controller.get( 'maxFiles' );
        Severity: Minor
        Found in js/media.js - About 1 hr to fix

          Function initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  initialize: function ( options ) {
                      this.controller = options.controller;
                      this.collection = this.controller.get( 'items' );
                      this.itemView = options.itemView || MediaItem;
                      this.getItemView = _.memoize( function ( item ) {
          Severity: Minor
          Found in js/media.js - About 1 hr to fix

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

                        this.$el.sortable( {
                            helper : 'clone',
                            start: function ( event, ui ) {
                                ui.placeholder.height( ui.helper.outerHeight() );
                                ui.placeholder.width( ui.helper.outerWidth() );
            Severity: Major
            Found in js/media.js and 1 other location - About 4 hrs to fix
            js/file.js on lines 68..77

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

            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

                function initMediaField() {
                    var $this = $( this ),
                        view = $this.data( 'view' );
            
                    if ( view ) {
            Severity: Major
            Found in js/media.js and 1 other location - About 3 hrs to fix
            js/image-advanced.js on lines 25..38

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

            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

                        this._switchFrame.on( 'open', function() {
                            var frameContent = this._switchFrame.content.get();
                            if ( frameContent && frameContent.collection ) {
                                frameContent.collection.mirroring._hasMore = true;
                                frameContent.collection.more();
            Severity: Major
            Found in js/media.js and 1 other location - About 2 hrs to fix
            js/media.js on lines 370..376

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

            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

                            this._frame.on( 'open', function() {
                                var frameContent = this._frame.content.get();
                                if ( frameContent && frameContent.collection ) {
                                    frameContent.collection.mirroring._hasMore = true;
                                    frameContent.collection.more();
            Severity: Major
            Found in js/media.js and 1 other location - About 2 hrs to fix
            js/media.js on lines 273..279

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

            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

                        this.listenTo( this.controller, 'change:full', function () {
                            this.$el.toggle( ! this.controller.get( 'full' ) );
                        } );
            Severity: Minor
            Found in js/media.js and 1 other location - About 55 mins to fix
            js/file-upload.js on lines 29..31

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

            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

            There are no issues that match your filters.

            Category
            Status