d3yii2/d3files

View on GitHub

Showing 71 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

              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

                    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

                            Method actionRemoveFiles has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

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

                              Function preview has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      preview: function (e) {
                                          this.handlers.modalMessages.empty();
                                          this.handlers.modalContent.empty();
                                          try {
                                              let m = this.getAttachmentData(e);
                              Severity: Minor
                              Found in assets/js/d3files-preview.js - About 1 hr to fix

                                Function css has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  function css(property, value) {
                                    if (arguments.length < 2) {
                                      var element = this[0];
                                      if (typeof property == 'string') {
                                        if (!element) return;
                                Severity: Minor
                                Found in assets/js/d3photo-view.js - About 1 hr to fix

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

                                      public function run($id, $hash)
                                      {
                                  
                                          // Pause every request
                                          sleep(1);
                                  Severity: Minor
                                  Found in components/DownloadShareAction.php - About 1 hr to fix

                                    Function init has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function init(): void
                                        {
                                            if (!$this->viewByExtensions) {
                                                $this->viewByExtensions = D3Files::getAllowedFileTypes();
                                            }
                                    Severity: Minor
                                    Found in widgets/D3FilesWidget.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 getAllByModelRecordIds has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public static function getAllByModelRecordIds(string $modelClass, array $ids): array
                                        {
                                            if (empty($ids)) {
                                                return [];
                                            }
                                    Severity: Minor
                                    Found in models/D3files.php - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language