luyadev/luya

View on GitHub

Showing 91 of 91 total issues

Function buildImporterQueue has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function buildImporterQueue()
    {
        $queue = [];
        foreach (Yii::$app->getApplicationModules() as $id => $module) {
            $response = $module->import($this);
Severity: Minor
Found in core/console/commands/ImportController.php - About 2 hrs 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 getIsAdmin has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIsAdmin()
    {
        if ($this->_isAdmin === null) {
            if ($this->getIsConsoleRequest() && !$this->forceWebRequest && !Yii::$app->hasModule('admin')) {
                $this->_isAdmin = false;
Severity: Minor
Found in core/web/Request.php - About 2 hrs 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 actionClone has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionClone($vendor = null, $repo = null)
    {
        // if `vendor/repo` notation is provided
        if ($vendor !== null && strpos($vendor, '/')) {
            list($vendor, $repo) = explode("/", $vendor);
Severity: Minor
Found in dev/RepoController.php - About 2 hrs 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 _computeTargetAndRootIntersection has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function(target, targetRect, rootRect) {
      // If the element isn't displayed, an intersection can't happen.
      if (window.getComputedStyle(target).display == 'none') return;
    
      var intersectionRect = targetRect;
Severity: Major
Found in core/resources/lazyload/intersectionObserver.polyfill.src.js - About 2 hrs to fix

    Method actionCreate has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function actionCreate(string $themeName = null)
        {
            Console::clearScreenBeforeCursor();
            
            $themeName = $this->prompt("Enter the name (lower case) of the theme you like to generate:", ['default' => $themeName]);
    Severity: Major
    Found in core/console/commands/ThemeController.php - About 2 hrs to fix

      Function trigger has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function trigger($name)
          {
              if (isset(static::$_hooks[$name])) {
                  $events = [];
                  
      Severity: Minor
      Found in core/Hook.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 play has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                      play() {
                          if (this.isPaused) {
                              return this.resume()
                          }
      
      
      Severity: Minor
      Found in core/resources/texttospeech/texttospeech.src.js - About 1 hr to fix

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

            if (!Object.preventExtensions) {
                Object.preventExtensions = function preventExtensions(object) {
                    if (Object(object) !== object) {
                        throw new TypeError('Object.preventExtensions can only be called on Objects.');
                    }
        core/resources/lazyload/intersectionObserver.polyfill.src.js on lines 478..488

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

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

                loadImage(image) {
                    const context = this
        
                    this.log('Image loading:', { id: image.id, image })
        
        
        Severity: Minor
        Found in core/resources/lazyload/lazyload.src.js - About 1 hr to fix

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

              if (!Object.seal) {
                  Object.seal = function seal(object) {
                      if (Object(object) !== object) {
                          throw new TypeError('Object.seal can only be called on Objects.');
                      }
          core/resources/lazyload/intersectionObserver.polyfill.src.js on lines 521..531

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

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

              IntersectionObserver.prototype._monitorIntersections = function(doc) {
                var win = doc.defaultView;
                if (!win) {
                  // Already destroyed.
                  return;
          Severity: Minor
          Found in core/resources/lazyload/intersectionObserver.polyfill.src.js - About 1 hr to fix

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

                public function beforeRun($app)
                {
                    foreach ($app->tags as $name => $config) {
                        TagParser::inject($name, $config);
                    }
            Severity: Minor
            Found in core/web/Bootstrap.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 buildTraceItem has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function buildTraceItem(array $item)
                {
                    $file = isset($item['file']) ? $item['file'] : null;
                    $line = isset($item['line']) ? $item['line'] : null;
                    $contextLine = null;
            Severity: Minor
            Found in core/traits/ErrorHandlerTrait.php - About 1 hr to fix

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

                      Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
                          if (isPrimitive(object)) {
                              throw new TypeError(ERR_NON_OBJECT + object);
                          }
              
              
              Severity: Minor
              Found in core/resources/lazyload/intersectionObserver.polyfill.src.js - About 1 hr to fix

                Method getInternalResolverArray has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function getInternalResolverArray()
                    {
                        if ($this->_resolved === null) {
                            $requestPathInfo = $this->trailingPathInfo();
                            $newRegex = $this->buildRegexPattern();
                Severity: Minor
                Found in core/web/CompositionResolver.php - About 1 hr to fix

                  Function generateClassName has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function generateClassName($tableName, $useSchemaName = null)
                      {
                          if (isset($this->classNames[$tableName])) {
                              return $this->classNames[$tableName];
                          }
                  Severity: Minor
                  Found in core/console/commands/BaseCrudController.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 actionCreate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function actionCreate()
                      {
                          Console::clearScreenBeforeCursor();
                          
                          $moduleName = $this->prompt("Enter the name of the module you like to generate:");
                  Severity: Minor
                  Found in core/console/commands/ModuleController.php - About 1 hr to fix

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

                        public function actionIndex()
                        {
                            // opcache reset should run in web context, but might be helpfull as well.
                            if (function_exists('opcache_reset')) {
                                @opcache_reset();
                    Severity: Minor
                    Found in core/console/commands/HealthController.php - About 1 hr to fix

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

                          public function run()
                          {
                              TextToSpeechAsset::register($this->view);
                      
                              $config = Json::htmlEncode([
                      Severity: Minor
                      Found in core/texttospeech/TextToSpeechWidget.php - About 1 hr to fix

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

                                Object.defineProperty = function defineProperty(object, property, descriptor) {
                                    if (isPrimitive(object)) {
                                        throw new TypeError(ERR_NON_OBJECT_TARGET + object);
                                    }
                                    if (isPrimitive(descriptor)) {
                        Severity: Minor
                        Found in core/resources/lazyload/intersectionObserver.polyfill.src.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language