Showing 30 of 30 total issues
FrontendAsset
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class FrontendAsset
{
/**
* The domain for assets.
*
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.
*
- Exclude checks
The class PackageAbstract has 13 public methods. Consider refactoring PackageAbstract to keep number of public methods under 10. Open
abstract class PackageAbstract
{
/**
* Package name.
*
- Read upRead up
- Exclude checks
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.
*
- Read upRead up
- Exclude checks
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;
/*
Asset
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Asset
{
private $path;
private $content;
private $location;
Avoid excessively long variable names like $extension_default_locations. Keep variable name length under 20. Open
public $extension_default_locations = [
'css' => 'header',
'js' => 'footer',
];
- Read upRead up
- Exclude checks
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'),
]);
Avoid using undefined variables such as '$path' which will lead to PHP notices. Open
$asset = Asset::createByContent($path, $content, $location);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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) {
- Read upRead up
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);
- Read upRead up
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);
- Read upRead up
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;
- Read upRead up
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;
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return "<?php app('FrontendAsset')->package($name); ?>";
Avoid too many return
statements within this method. Open
return "<?php app('FrontendAsset')->package($name); ?>";
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)
- Read upRead up
- Exclude checks
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;
- Read upRead up
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"