Showing 282 of 291 total issues
Avoid excessively long variable names like $hasUnderscoreExceptions. Keep variable name length under 20. Open
$hasUnderscoreExceptions = (count($this->underscoreExceptions) > 0);
- 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 __invoke
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke(Project $project, OutputInterface $output)
{
$stopwatch = $project->get('cmd_options.stopwatch', false);
/** @var ContentTypeFactory $contentTypes */
Function arrayMergeRecursive
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function arrayMergeRecursive(array &$left, array &$right)
{
$merged = $left;
foreach ($right as $key => $value) {
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
- 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
Method encodePart
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function encodePart($part)
{
if (strpos($part, '?') !== false) {
if (strpos($part, '?') === 0) {
$output = '?';
Function generate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function generate(Project $project)
{
if ($generators = $this->file->getData('generator')) {
// Kick off the generation with the first generator. Because File generators can either mutate the current File
// or generate an array of File's we then continue the generation with a while loop until all generators have been
- 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
Method __invoke
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke(Project $project, OutputInterface $output)
{
if ($project->get('cmd_options.json') !== true) {
return true;
}
Method fire
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function fire()
{
$currentWorkingDirectory = $this->input->getOption('site-dir');
// If the current working directory does not exist, do nothing and exit. This is often due to a borked --site-dir
Function iterateProjectContentTypes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function iterateProjectContentTypes(ContentTypeFactory $contentTypes, Project $project, OutputInterface $output)
{
/** @var ContentType $contentType */
foreach ($contentTypes->all() as $contentType) {
$output->writeln('[+] Compiling content within ['.$contentType->getName().']');
- 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 fire
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function fire()
{
$currentWorkingDirectory = $this->input->getOption('site-dir');
// If the current working directory does not exist, do nothing and exit. This is often due to a borked --site-dir
- 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
Method render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render(array $data = [])
{
$this->data($data);
unset($data);
extract($this->data);
Method __invoke
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke(Project $project, OutputInterface $output)
{
//
// Loop over all project files, those that have a data source via the `use` method should have the relevant
// content type data source passed to them. Those that have generators associated with them (such as those using
Method getNestedValueByKey
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getNestedValueByKey($key)
{
if (isset($this->nestedKeyCache[$key])) {
return $this->nestedKeyCache[$key];
}
Method fire
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function fire()
{
try {
$this->tapestry->setInput($this->input);
$this->tapestry->setOutput($this->output);
Function collectProjectFilesUseData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function collectProjectFilesUseData(Project $project)
{
/** @var File $file */
foreach ($project['compiled'] as $file) {
if (! $uses = $file->getData('use')) {
- 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 checkForFileGeneratorError
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function checkForFileGeneratorError(OutputInterface $output)
{
if (! $this->allFilesGenerated()) {
foreach ($this->files as &$file) {
if ($uses = $file->getData('generator')) {
- 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 mutateFilesToFilesystemInterfaces
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function mutateFilesToFilesystemInterfaces(Project $project, Cache $cache)
{
foreach ($this->files as &$file) {
/** @var CachedFile $cachedFile */
if ($cachedFile = $cache->getItem($file->getUid())) {
- 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 __invoke
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __invoke(Project $project, OutputInterface $output)
{
$stopwatch = $project->get('cmd_options.stopwatch', false);
/** @var ContentTypeFactory $contentTypes */
- 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
Method generate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate(Project $project)
{
$generated = [];
if (! $uses = $this->file->getData('use')) {
Method mutateProjectFiles
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function mutateProjectFiles(Project $project)
{
/** @var ContentRendererFactory $contentRenderers */
$contentRenderers = $project->get('content_renderers');
Method fire
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function fire()
{
if (! $this->canExecute) {
return 0;
}