AsgardCms/Core

View on GitHub

Showing 16 of 16 total issues

File available-locales.php has 293 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

return [
    'ace' => ['name' => 'Achinese', 'script' => 'Latn', 'native' => 'Aceh'],
    'af' => ['name' => 'Afrikaans', 'script' => 'Latn', 'native' => 'Afrikaans'],
Severity: Minor
Found in Config/available-locales.php - About 3 hrs to fix

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

        public function fire(Command $command)
        {
            if ($command->option('verbose')) {
                $command->blockMessage('Seeds', 'Running the module seeds ...', 'comment');
            }
    Severity: Major
    Found in Console/Installers/Scripts/ModuleSeeders.php and 2 other locations - About 1 hr to fix
    Console/Installers/Scripts/ModuleAssets.php on lines 22..35
    Console/Installers/Scripts/ModuleMigrator.php on lines 25..38

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

    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 3 locations. Consider refactoring.
    Open

        public function fire(Command $command)
        {
            if ($command->option('verbose')) {
                $command->blockMessage('Migrations', 'Starting the module migrations ...', 'comment');
            }
    Severity: Major
    Found in Console/Installers/Scripts/ModuleMigrator.php and 2 other locations - About 1 hr to fix
    Console/Installers/Scripts/ModuleAssets.php on lines 22..35
    Console/Installers/Scripts/ModuleSeeders.php on lines 21..34

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

    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 3 locations. Consider refactoring.
    Open

        public function fire(Command $command)
        {
            if ($command->option('verbose')) {
                $command->blockMessage('Module assets', 'Publishing module assets ...', 'comment');
            }
    Severity: Major
    Found in Console/Installers/Scripts/ModuleAssets.php and 2 other locations - About 1 hr to fix
    Console/Installers/Scripts/ModuleMigrator.php on lines 25..38
    Console/Installers/Scripts/ModuleSeeders.php on lines 21..34

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

    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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function save(array $options = array())
        {
            $tempTranslations = $this->translations;
            if ($this->exists) {
                if (count($this->getDirty()) > 0) {
    Severity: Minor
    Found in Internationalisation/Translatable.php - About 45 mins 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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct(Authentication $auth, Store $session, Request $request, Redirector $redirect, Application $application)
    Severity: Minor
    Found in Http/Middleware/AdminMiddleware.php - About 35 mins to fix

      Function separateLanguages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function separateLanguages($data)
          {
              $cleanedData = [];
              foreach ($data as $key => $value) {
                  if (is_array($value)) {
      Severity: Minor
      Found in Internationalisation/Helper.php - About 35 mins 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 allPublicThemes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function allPublicThemes()
          {
              $themes = [];
              if (!$this->getFinder()->isDirectory($this->path)) {
                  return $themes;
      Severity: Minor
      Found in Foundation/Theme/ThemeManager.php - About 35 mins 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

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in Internationalisation/Translatable.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return $this->loadTranslationsFrom($module->getPath() . '/Resources/lang', $moduleName);
        Severity: Major
        Found in Providers/CoreServiceProvider.php - About 30 mins to fix

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

              public function findByMany(array $ids)
              {
                  $tagIdentifier = json_encode($ids);
          
                  return $this->cache
          Severity: Minor
          Found in Repositories/Cache/BaseCacheDecorator.php and 1 other location - About 30 mins to fix
          Repositories/Cache/BaseCacheDecorator.php on lines 143..154

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

          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

              public function findByAttributes(array $attributes)
              {
                  $tagIdentifier = json_encode($attributes);
          
                  return $this->cache
          Severity: Minor
          Found in Repositories/Cache/BaseCacheDecorator.php and 1 other location - About 30 mins to fix
          Repositories/Cache/BaseCacheDecorator.php on lines 181..192

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

          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 registerLanguageNamespace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function registerLanguageNamespace(Module $module)
              {
                  $moduleName = $module->getName();
          
                  $langPath = base_path("resources/lang/$moduleName");
          Severity: Minor
          Found in Providers/CoreServiceProvider.php - About 25 mins 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 setLocalesConfigurations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private function setLocalesConfigurations()
              {
                  if (! $this->app['asgard.isInstalled']) {
                      return;
                  }
          Severity: Minor
          Found in Providers/CoreServiceProvider.php - About 25 mins 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 getValidatorInstance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getValidatorInstance()
              {
                  $factory = $this->container->make('Illuminate\Validation\Factory');
                  if (method_exists($this, 'validator')) {
                      return $this->container->call([$this, 'validator'], compact('factory'));
          Severity: Minor
          Found in Internationalisation/BaseFormRequest.php - About 25 mins 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 saveTranslatedProperties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function saveTranslatedProperties($model, $data)
              {
                  foreach ($data as $lang => $value) {
                      if (is_array($value)) {
                          foreach ($value as $key => $input) {
          Severity: Minor
          Found in Internationalisation/Helper.php - About 25 mins 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

          Severity
          Category
          Status
          Source
          Language