wikimedia/mediawiki-extensions-Translate

View on GitHub
resources/src/ext.translate.groupselector/ui.position.js

Summary

Maintainability
F
4 days
Test Coverage

Function positionElement has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function positionElement( $targetElem, options ) {
    // Make a copy, we don't want to modify arguments
    options = $.extend( {}, options );

    var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
Severity: Major
Found in resources/src/ext.translate.groupselector/ui.position.js - About 4 hrs to fix

    File ui.position.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable */
    /*!
     * Positions elements relative to other elements.
     * Borrowed from jquery.ui.position and updated to remove unused code.
     * Does not pollute the global jQuery or jQuery.ui objects
    Severity: Minor
    Found in resources/src/ext.translate.groupselector/ui.position.js - About 2 hrs to fix

      Function left has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          left: function ( position, data ) {
              var within = data.within,
                  withinOffset = within.offset.left + within.scrollLeft,
                  outerWidth = within.width,
                  offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
      Severity: Minor
      Found in resources/src/ext.translate.groupselector/ui.position.js - 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 top has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          top: function ( position, data ) {
              var within = data.within,
                  withinOffset = within.offset.top + within.scrollTop,
                  outerHeight = within.height,
                  offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
      Severity: Minor
      Found in resources/src/ext.translate.groupselector/ui.position.js - 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 top has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          top: function ( position, data ) {
              var within = data.within,
                  withinOffset = within.offset.top + within.scrollTop,
                  outerHeight = within.height,
                  offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
      Severity: Minor
      Found in resources/src/ext.translate.groupselector/ui.position.js - About 1 hr to fix

        Function left has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            left: function ( position, data ) {
                var within = data.within,
                    withinOffset = within.offset.left + within.scrollLeft,
                    outerWidth = within.width,
                    offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
        Severity: Minor
        Found in resources/src/ext.translate.groupselector/ui.position.js - About 1 hr to fix

          Function getDimensions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getDimensions( elem ) {
              var raw = elem[ 0 ];
              if ( raw.nodeType === 9 ) {
                  return {
                      width: elem.width(),
          Severity: Minor
          Found in resources/src/ext.translate.groupselector/ui.position.js - About 1 hr to fix

            Function getScrollInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function getScrollInfo( within ) {
                var overflowX = within.isWindow || within.isDocument ? '' :
                        within.element.css( 'overflow-x' ),
                    overflowY = within.isWindow || within.isDocument ? '' :
                        within.element.css( 'overflow-y' ),
            Severity: Minor
            Found in resources/src/ext.translate.groupselector/ui.position.js - About 45 mins 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 positionElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function positionElement( $targetElem, options ) {
                // Make a copy, we don't want to modify arguments
                options = $.extend( {}, options );
            
                var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
            Severity: Minor
            Found in resources/src/ext.translate.groupselector/ui.position.js - About 25 mins 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

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

                    if ( overTop < 0 ) {
                        newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
                            outerHeight - withinOffset;
                        if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
                            position.top += myOffset + atOffset + offset;
            Severity: Major
            Found in resources/src/ext.translate.groupselector/ui.position.js and 1 other location - About 7 hrs to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 148..160

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

            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

                    if ( overLeft < 0 ) {
                        newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
                            outerWidth - withinOffset;
                        if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
                            position.left += myOffset + atOffset + offset;
            Severity: Major
            Found in resources/src/ext.translate.groupselector/ui.position.js and 1 other location - About 7 hrs to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 184..196

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

            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

                if ( options.at[ 1 ] === 'bottom' ) {
                    basePosition.top += targetHeight;
                } else if ( options.at[ 1 ] === 'center' ) {
                    basePosition.top += targetHeight / 2;
                }
            Severity: Major
            Found in resources/src/ext.translate.groupselector/ui.position.js and 3 other locations - About 1 hr to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 260..264
            resources/src/ext.translate.groupselector/ui.position.js on lines 290..294
            resources/src/ext.translate.groupselector/ui.position.js on lines 296..300

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

            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

                if ( options.at[ 0 ] === 'right' ) {
                    basePosition.left += targetWidth;
                } else if ( options.at[ 0 ] === 'center' ) {
                    basePosition.left += targetWidth / 2;
                }
            Severity: Major
            Found in resources/src/ext.translate.groupselector/ui.position.js and 3 other locations - About 1 hr to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 266..270
            resources/src/ext.translate.groupselector/ui.position.js on lines 290..294
            resources/src/ext.translate.groupselector/ui.position.js on lines 296..300

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

            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

                    if ( options.my[ 0 ] === 'right' ) {
                        position.left -= elemWidth;
                    } else if ( options.my[ 0 ] === 'center' ) {
                        position.left -= elemWidth / 2;
                    }
            Severity: Major
            Found in resources/src/ext.translate.groupselector/ui.position.js and 3 other locations - About 1 hr to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 260..264
            resources/src/ext.translate.groupselector/ui.position.js on lines 266..270
            resources/src/ext.translate.groupselector/ui.position.js on lines 296..300

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

            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

                    if ( options.my[ 1 ] === 'bottom' ) {
                        position.top -= elemHeight;
                    } else if ( options.my[ 1 ] === 'center' ) {
                        position.top -= elemHeight / 2;
                    }
            Severity: Major
            Found in resources/src/ext.translate.groupselector/ui.position.js and 3 other locations - About 1 hr to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 260..264
            resources/src/ext.translate.groupselector/ui.position.js on lines 266..270
            resources/src/ext.translate.groupselector/ui.position.js on lines 290..294

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

            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

                        atOffset = data.at[ 0 ] === 'left' ?
                            data.targetWidth :
                            data.at[ 0 ] === 'right' ?
                                -data.targetWidth :
                                0,
            Severity: Minor
            Found in resources/src/ext.translate.groupselector/ui.position.js and 1 other location - About 50 mins to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 176..180

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

            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

                        atOffset = data.at[ 1 ] === 'top' ?
                            data.targetHeight :
                            data.at[ 1 ] === 'bottom' ?
                                -data.targetHeight :
                                0,
            Severity: Minor
            Found in resources/src/ext.translate.groupselector/ui.position.js and 1 other location - About 50 mins to fix
            resources/src/ext.translate.groupselector/ui.position.js on lines 139..143

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

            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