hnhdigital-os/laravel-frontend-asset-loader

View on GitHub

Showing 30 of 30 total issues

FrontendAsset has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class FrontendAsset
{
    /**
     * The domain for assets.
     *
Severity: Minor
Found in src/FrontendAsset.php - About 3 hrs to fix

    The class FrontendAsset has an overall complexity of 75 which is very high. The configured complexity threshold is 50.
    Open

    class FrontendAsset
    {
        /**
         * The domain for assets.
         *
    Severity: Minor
    Found in src/FrontendAsset.php by phpmd

    The class PackageAbstract has 13 public methods. Consider refactoring PackageAbstract to keep number of public methods under 10.
    Open

    abstract class PackageAbstract
    {
        /**
         * Package name.
         *
    Severity: Minor
    Found in src/PackageAbstract.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    The class FrontendAsset has 23 public methods. Consider refactoring FrontendAsset to keep number of public methods under 10.
    Open

    class FrontendAsset
    {
        /**
         * The domain for assets.
         *
    Severity: Minor
    Found in src/FrontendAsset.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

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

    <?php
    
    namespace HnhDigital\LaravelFrontendAssetLoader;
    
    /*
    Severity: Minor
    Found in src/FrontendAsset.php - About 3 hrs to fix

      Asset has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Asset
      {
          private $path;
          private $content;
          private $location;
      Severity: Minor
      Found in src/Asset.php - About 2 hrs to fix

        Avoid excessively long variable names like $extension_default_locations. Keep variable name length under 20.
        Open

            public $extension_default_locations = [
                'css'  => 'header',
                'js'   => 'footer',
            ];
        Severity: Minor
        Found in src/FrontendAsset.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Method boot has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function boot()
            {
                $this->publishes([
                    __DIR__.'/../config/config.php' => config_path('hnhdigital/assets.php'),
                ]);
        Severity: Minor
        Found in src/ServiceProvider.php - About 1 hr to fix

          Avoid using undefined variables such as '$path' which will lead to PHP notices.
          Open

                  $asset = Asset::createByContent($path, $content, $location);
          Severity: Minor
          Found in src/FrontendAsset.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Avoid using undefined variables such as '$file' which will lead to PHP notices.
          Open

                  $path = str_replace('.', '/', $file);
          Severity: Minor
          Found in src/FrontendAsset.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Function parseExtension has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parseExtension($path, $location = null)
              {
                  $key = null;
          
                  foreach ($this->extension_mapping as $store => $extensions) {
          Severity: Minor
          Found in src/FrontendAsset.php - About 55 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 autoloadAssets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function autoloadAssets($extensions, $path)
              {
                  // Force array.
                  $extensions = Arr::wrap($extensions);
          
          
          Severity: Minor
          Found in src/FrontendAsset.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

          Function autoloadWildcardAssets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function autoloadWildcardAssets($extensions, $path)
              {
                  // Force array.
                  $extensions = Arr::wrap($extensions);
          
          
          Severity: Minor
          Found in src/FrontendAsset.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

          Function renderInline has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function renderInline($location)
              {
                  $result = '';
                  $path = $this->path;
          
          
          Severity: Minor
          Found in src/Asset.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

          Avoid too many return statements within this method.
          Open

                      return '/assets/'.$path;
          Severity: Major
          Found in src/FrontendAsset.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return '';
            Severity: Major
            Found in src/FrontendAsset.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return "<?php app('FrontendAsset')->package($name); ?>";
              Severity: Major
              Found in src/ServiceProvider.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return "<?php app('FrontendAsset')->package($name); ?>";
                Severity: Major
                Found in src/ServiceProvider.php - About 30 mins to fix

                  The method packageVersion has a boolean flag argument $version, which is a certain sign of a Single Responsibility Principle violation.
                  Open

                      public function packageVersion($name, $version = false)
                  Severity: Minor
                  Found in src/FrontendAsset.php by phpmd

                  BooleanArgumentFlag

                  Since: 1.4.0

                  A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                  Example

                  class Foo {
                      public function bar($flag = true) {
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                  Function url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function url($path)
                      {
                          // Detect path points to external url.
                          if (stripos($path, '://') !== false) {
                              return $path;
                  Severity: Minor
                  Found in src/FrontendAsset.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