superdesk/superdesk-client-core

View on GitHub
scripts/core/upload/image-crop-directive.ts

Summary

Maintainability
F
3 days
Test Coverage

Function link has 188 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                link: function(scope, elem) {
                    var img, cropData, selectionWidth, selectionHeight, jcropApi;

                    /**
                * Test if crop data a equals to crop data b
Severity: Major
Found in scripts/core/upload/image-crop-directive.ts - About 7 hrs to fix

    File image-crop-directive.ts has 341 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {gettext} from 'core/utils';
    
    export default angular.module('superdesk.core.upload.imagecrop', [
        'superdesk.core.translate',
    ])
    Severity: Minor
    Found in scripts/core/upload/image-crop-directive.ts - About 4 hrs to fix

      Function link has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  link: function(scope, element, attrs, vm) {
                  // init directive element style
                      element.css({
                          position: 'relative',
                          display: 'block',
      Severity: Major
      Found in scripts/core/upload/image-crop-directive.ts - About 3 hrs to fix

        Function updateWhenImageIsReady has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                        function updateWhenImageIsReady() {
                            var $img = element.find('.image-point__image').get(0);
        
                            function drawPointsFromModel() {
                                drawPoint($img);
        Severity: Minor
        Found in scripts/core/upload/image-crop-directive.ts - About 1 hr to fix

          Function refreshImage has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                              function refreshImage(src, setSelect) {
                                  img = imageFactory.makeInstance();
                                  img.onload = function() {
                                      if (!src || scope.showMinSizeError
                                      && !validateConstraints(scope.original, scope.rendition)) {
          Severity: Minor
          Found in scripts/core/upload/image-crop-directive.ts - About 1 hr to fix

            Function onMouseEvents has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                                (function onMouseEvents(_$img) {
                                    var debouncedPoiUpdateModel = _.debounce((newPoi) => {
                                        vm.updatePOI(newPoi);
                                    }, 500);
            
            
            Severity: Minor
            Found in scripts/core/upload/image-crop-directive.ts - About 1 hr to fix

              Function onload has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                                      img.onload = function() {
                                          if (!src || scope.showMinSizeError
                                          && !validateConstraints(scope.original, scope.rendition)) {
                                              return;
                                          }
              Severity: Minor
              Found in scripts/core/upload/image-crop-directive.ts - About 1 hr to fix

                Function drawPoint has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                                function drawPoint(img, poi = vm.poi) {
                                    var topOffset = poi.y * img.height - circleRadius;
                                    var leftOffset = poi.x * img.width - circleRadius;
                                    var verticalLeftOffset = leftOffset + circleRadius - lineThickness / 2;
                                    var horizontalTopffset = topOffset + circleRadius - lineThickness / 2;
                Severity: Minor
                Found in scripts/core/upload/image-crop-directive.ts - About 1 hr to fix

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

                                          if (center.y > scope.original.height - selectionHeight / 2) {
                                              center.y = scope.original.height - selectionHeight / 2;
                                          }
                  Severity: Major
                  Found in scripts/core/upload/image-crop-directive.ts and 1 other location - About 1 hr to fix
                  scripts/core/upload/image-crop-directive.ts on lines 168..170

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

                  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 (center.x > scope.original.width - selectionWidth / 2) {
                                              center.x = scope.original.width - selectionWidth / 2;
                                          }
                  Severity: Major
                  Found in scripts/core/upload/image-crop-directive.ts and 1 other location - About 1 hr to fix
                  scripts/core/upload/image-crop-directive.ts on lines 171..173

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

                  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

                                      $poiRight.css({
                                          width: img.width - (leftOffset + 2 * circleRadius),
                                          top: horizontalTopffset,
                                          left: leftOffset + 2 * circleRadius,
                                      });
                  Severity: Minor
                  Found in scripts/core/upload/image-crop-directive.ts and 1 other location - About 50 mins to fix
                  scripts/core/upload/image-crop-directive.ts on lines 369..373

                  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

                                      $poiBottom.css({
                                          height: img.height - (topOffset + 2 * circleRadius),
                                          left: verticalLeftOffset,
                                          top: topOffset + 2 * circleRadius,
                                      });
                  Severity: Minor
                  Found in scripts/core/upload/image-crop-directive.ts and 1 other location - About 50 mins to fix
                  scripts/core/upload/image-crop-directive.ts on lines 360..364

                  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