d3yii2/d3files

View on GitHub

Showing 115 of 115 total issues

Function _addEvents has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      value: function _addEvents() {
        var _this6 = this;

        this.$stage.off(WHEEL_EVENT + EVENT_NS).on(WHEEL_EVENT + EVENT_NS, function (e) {
          $('.photoviewer-image').removeClass('starting-position');
Severity: Minor
Found in assets/js/d3photo-view.js - About 1 hr to fix

    Method actionUnusedFiles has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function actionUnusedFiles(string $modelName): int
        {
    
            $modelMN = new D3filesModelName();
            if (!$modelNameId = $modelMN->getByName($modelName, false)) {
    Severity: Minor
    Found in controllers/CleanFilesController.php - About 1 hr to fix

      Function draggable has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          draggable: function draggable(modal, dragHandle, dragCancel) {
            var _this = this;
      
            var isDragging = false;
            var startX = 0;
      Severity: Minor
      Found in assets/js/d3photo-view.js - About 1 hr to fix

        Function extend has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          D.extend = D.fn.extend = function () {
            var options, name, src, copy, copyIsArray, clone,
              target = arguments[0] || {},
              i = 1,
              length = arguments.length,
        Severity: Minor
        Found in assets/js/d3photo-view.js - About 1 hr to fix

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

                var getImageOpts = function getImageOpts(dir, offsetX, offsetY) {
                  // Image should not move when modal width to the min width
                  // The minwidth is modal width, so we should clac the stage minwidth
                  var widthDiff = offsetX + modalData.w > minWidth ? stageData.w - imgWidth + offsetX - δ : minWidth - (modalData.w - stageData.w) - imgWidth - δ;
                  var heightDiff = offsetY + modalData.h > minHeight ? stageData.h - imgHeight + offsetY + δ : minHeight - (modalData.h - stageData.h) - imgHeight + δ;
          Severity: Minor
          Found in assets/js/d3photo-view.js - About 1 hr to fix

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

                  var getModalOpts = function getModalOpts(dir, offsetX, offsetY) {
                    // Modal should not move when its width to the minwidth
                    var modalLeft = -offsetX + modalData.w > minWidth ? offsetX + modalData.l : modalData.l + modalData.w - minWidth;
                    var modalTop = -offsetY + modalData.h > minHeight ? offsetY + modalData.t : modalData.t + modalData.h - minHeight;
                    var opts = {
            Severity: Minor
            Found in assets/js/d3photo-view.js - About 1 hr to fix

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

                      var heightDiff2 = -offsetY + modalData.h > minHeight ? stageData.h - imgHeight - offsetY + δ : minHeight - (modalData.h - stageData.h) - imgHeight + δ; // Get image position in dragging
              Severity: Major
              Found in assets/js/d3photo-view.js and 1 other location - About 1 hr to fix
              assets/js/d3photo-view.js on lines 1725..1725

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

              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

                      var widthDiff2 = -offsetX + modalData.w > minWidth ? stageData.w - imgWidth - offsetX - δ : minWidth - (modalData.w - stageData.w) - imgWidth - δ;
              Severity: Major
              Found in assets/js/d3photo-view.js and 1 other location - About 1 hr to fix
              assets/js/d3photo-view.js on lines 1726..1726

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

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

                  public function actionRemoveOlderThan(string $modelName, int $months, string $sqlLikeFileName = null): int
                  {
                      $date = new DateTime();
                      $date->sub(new DateInterval('P' . $months . 'M'));
                      $this->out('Clrear oldest ' . $date->format('Y-m-d H:i:s'));
              Severity: Minor
              Found in controllers/CleanFilesController.php - About 1 hr to fix

                Function setModalSize has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      value: function setModalSize(img) {
                        var _this2 = this;
                
                        var winWidth = $W.width();
                        var winHeight = $W.height();
                Severity: Minor
                Found in assets/js/d3photo-view.js - About 1 hr to fix

                  Function setImageSize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        value: function setImageSize(img) {
                          var stageData = {
                            w: this.$stage.width(),
                            h: this.$stage.height()
                          };
                  Severity: Minor
                  Found in assets/js/d3photo-view.js - About 1 hr to fix

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

                            var heightDiff = offsetY + modalData.h > minHeight ? stageData.h - imgHeight + offsetY + δ : minHeight - (modalData.h - stageData.h) - imgHeight + δ;
                    Severity: Major
                    Found in assets/js/d3photo-view.js and 1 other location - About 1 hr to fix
                    assets/js/d3photo-view.js on lines 1723..1723

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

                    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

                            var widthDiff = offsetX + modalData.w > minWidth ? stageData.w - imgWidth + offsetX - δ : minWidth - (modalData.w - stageData.w) - imgWidth - δ;
                    Severity: Major
                    Found in assets/js/d3photo-view.js and 1 other location - About 1 hr to fix
                    assets/js/d3photo-view.js on lines 1724..1724

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

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

                        init: function (selector, context) {
                          var dom;
                          // If nothing given, return an empty D collection
                          if (!selector) {
                            return this;
                    Severity: Minor
                    Found in assets/js/d3photo-view.js - About 1 hr to fix

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

                            var dragMove = function dragMove(e) {
                              e = e || window.event;
                              e.preventDefault();
                      
                              if (isDragging) {
                      Severity: Minor
                      Found in assets/js/d3photo-view.js - About 1 hr to fix

                        Function run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function run(int $id, string $model_name = ''): array
                            {
                                try {
                                    if (!$model_name) {
                                        $model_name = $this->modelName;
                        Severity: Minor
                        Found in components/DeleteAction.php - 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

                        Method run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function run(int $id, string $model_name = ''): array
                            {
                                try {
                                    if (!$model_name) {
                                        $model_name = $this->modelName;
                        Severity: Minor
                        Found in components/DeleteAction.php - About 1 hr to fix

                          Function domMani has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            var domMani = function (elem, args, fn, inside) {
                              // arguments can be nodes, arrays of nodes, D objects and HTML strings
                              var argType,
                                nodes = D.map(args, function (arg) {
                                  var arr = [];
                          Severity: Minor
                          Found in assets/js/d3photo-view.js - About 1 hr to fix

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

                                        if (!Yii::$app->getModule('d3files')->disableController) {
                                            if (is_array($this->modelName) && !in_array($model_name, $this->modelName, true)) {
                                                throw new HttpException(422, 'Can not delete file for requested model');
                                            }
                            
                            
                            Severity: Major
                            Found in components/DeleteAction.php and 1 other location - About 1 hr to fix
                            components/DownloadAction.php on lines 51..59

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

                            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(!Yii::$app->getModule('d3files')->disableController){
                                        if (is_array($this->modelName) && !in_array($model_name, $this->modelName, true)) {
                                            throw new HttpException(422, 'Can not upload file for requested model');
                                        }
                            
                            Severity: Major
                            Found in components/DownloadAction.php and 1 other location - About 1 hr to fix
                            components/DeleteAction.php on lines 34..42

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language