luyadev/luya-module-admin

View on GitHub

Showing 503 of 503 total issues

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

    public function run($id)
    {
        $model = $this->modelClass::ngRestFind()->byPrimaryKey($id)->one();

        if (!$model) {
Severity: Minor
Found in src/ngrest/base/actions/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

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

var observeLogin = function (form, url, secureUrl, twoFaUrl) {

    $(form).submit(function (e) {
        $('#errorsContainer').hide();
        $('.login-btn[type="submit"]').attr('disabled', true);
Severity: Minor
Found in src/resources/js/login.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 ensureFileUpload has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function ensureFileUpload($fileSource, $fileName)
    {
        // throw exception if source or name is empty
        if (empty($fileSource) || empty($fileName)) {
            throw new Exception("Filename and source can not be empty.");
Severity: Minor
Found in src/storage/BaseFileSystemStorage.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

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

    public function createImage($fileId, $filterId)
    {
        gc_collect_cycles();

        $image = StorageImage::find()->where(['file_id' => $fileId, 'filter_id' => $filterId])->one();
Severity: Minor
Found in src/storage/BaseFileSystemStorage.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

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

    public function actionCleanupImageTable()
    {
        $rows = Yii::$app->db->createCommand('SELECT file_id, filter_id, COUNT(*) as count FROM {{%admin_storage_image}} GROUP BY file_id, filter_id HAVING COUNT(*) > 1')->queryAll();

        if (empty($rows)) {
Severity: Minor
Found in src/commands/StorageController.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

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

    protected function startImages()
    {
        $imageCount = 0;
        // sync images
        foreach ((new \luya\admin\image\Query())->all() as $image) {
Severity: Minor
Found in src/proxy/ClientTransfer.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

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

    public function getUrlRules()
    {
        $rules = [];
        // get all rules from the urlManager
        foreach ($this->urlManager->rules as $rule) {
Severity: Minor
Found in src/openapi/Generator.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

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

        controller: ['$scope', function ($scope) {

            $scope.input = { showWindow: true };

            $scope.content = null;
Severity: Minor
Found in src/resources/js/directives.js - About 1 hr to fix

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

            template: function () {
                return '' +
                    '<div class="form-group form-side-by-side" ng-class="{\'input--hide-label\': i18n}">' +
                    '<div class="form-side form-side-label">' +
                    '<label>{{label}}</label>' +
    Severity: Minor
    Found in src/resources/js/formdirectives.js - About 1 hr to fix

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

              link: function ($scope, $element, $attrs) {
      
                  $scope.$watch('trigger', function (n, o) {
                      if (n == 0) {
                          $($attrs.resizerLeft).removeAttr('style');
      Severity: Minor
      Found in src/resources/js/directives.js - About 1 hr to fix

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

            public function safeUp()
            {
                $this->createTable("{{%admin_queue}}", [
                    'id' => $this->primaryKey(),
                    'channel' => $this->string()->notNull(),
        Severity: Minor
        Found in src/migrations/m181023_135132_scheduler.php - About 1 hr to fix

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

              private static function log($type, $message, $trace, $groupIdentifier)
              {
                  $hashArray = static::getHashArray($message, $groupIdentifier);
          
                  $file = 'unknown';
          Severity: Minor
          Found in src/models/Logger.php - About 1 hr to fix

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

                    $scope.isSelectableMaxYear = function isSelectableMaxYear(year) {
                      if (!!$scope.dateMaxLimit &&
                        year > new Date($scope.dateMaxLimit).getFullYear()) {
            
                        return false;
            src/resources/vendorlibs/angularjs-datepicker/angular-datepicker.js on lines 864..872

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

            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

                    $scope.isSelectableMinYear = function isSelectableMinYear(year) {
                      if (!!$scope.dateMinLimit &&
                        year < new Date($scope.dateMinLimit).getFullYear()) {
            
                        return false;
            src/resources/vendorlibs/angularjs-datepicker/angular-datepicker.js on lines 854..862

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

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

                        scope.alignModal = function() {
                            var documentSize = {width: $(document).width(), height: element.parents('.luya-content')[0].scrollHeight || $(document).height()};
                            var buttonBcr = button[0].getBoundingClientRect();
            
                            var buttonSpaceRight = documentSize.width - (buttonBcr.left + buttonBcr.width + (modalMargin * 2));
            Severity: Minor
            Found in src/resources/js/scheduler.js - About 1 hr to fix

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

                  public function actionIndex()
                  {
                      $userId = Yii::$app->adminuser->id;
              
                      // clear user online list
              Severity: Minor
              Found in src/apis/TimestampController.php - About 1 hr to fix

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

                    public function actionIndex()
                    {
                        $tempName = null;
                        if ($this->identifier === null) {
                            $this->identifier = Inflector::variablize($this->prompt('Enter the filter identifier: (e.g. profilePicture)', ['required' => true, 'pattern' => '/^[a-zA-Z0-9]+$/i', 'error' => 'The filter identifer can only contain a-z,A-Z,0-9']));
                Severity: Minor
                Found in src/commands/FilterController.php - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                    "pluralCat": function(n, opt_precision) {  var i = n | 0;  var vf = getVF(n, opt_precision);  if (vf.v == 0 && i % 10 == 1 && i % 100 != 11) {    return PLURAL_CATEGORY.ONE;  }  if (vf.v == 0 && i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 12 || i % 100 > 14)) {    return PLURAL_CATEGORY.FEW;  }  if (vf.v == 0 && i % 10 == 0 || vf.v == 0 && i % 10 >= 5 && i % 10 <= 9 || vf.v == 0 && i % 100 >= 11 && i % 100 <= 14) {    return PLURAL_CATEGORY.MANY;  }  return PLURAL_CATEGORY.OTHER;}
                  Severity: Critical
                  Found in src/resources/angular-i18n/angular-locale_ru.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                    if ( (!scope.pop || lastValue != scope.tooltipText)
                                      && (typeof scope.tooltipDisabled === 'undefined' || scope.tooltipDisabled === false)
                                      && (scope.tooltipText || scope.tooltipImageUrl || scope.tooltipPreviewUrl) ) {
                    
                                        lastValue = scope.tooltipText
                    Severity: Critical
                    Found in src/resources/js/directives.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                        "pluralCat": function(n, opt_precision) {  var i = n | 0;  var vf = getVF(n, opt_precision);  if (vf.v == 0 && i % 10 == 1 && i % 100 != 11) {    return PLURAL_CATEGORY.ONE;  }  if (vf.v == 0 && i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 12 || i % 100 > 14)) {    return PLURAL_CATEGORY.FEW;  }  if (vf.v == 0 && i % 10 == 0 || vf.v == 0 && i % 10 >= 5 && i % 10 <= 9 || vf.v == 0 && i % 100 >= 11 && i % 100 <= 14) {    return PLURAL_CATEGORY.MANY;  }  return PLURAL_CATEGORY.OTHER;}
                      Severity: Critical
                      Found in src/resources/angular-i18n/angular-locale_ua.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language