modifySubmoduleArray accesses the super-global variable $_SERVER. Open
function modifySubmoduleArray($original) {
$modifiedArray = array();
foreach ($original as $key => $value) {
$filenameArray = array();
$key = str_replace("/", DIRECTORY_SEPARATOR, $_SERVER["DOCUMENT_ROOT"] . $key);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Function removeEmptyDirectories
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function removeEmptyDirectories($submoduleArray) {
foreach ($submoduleArray as $submoduleKey => $submoduleValue) {
$dir = new RecursiveDirectoryIterator($submoduleKey, FilesystemIterator::SKIP_DOTS);
foreach (new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
if ($file->isDir()) {
- 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 removeSubmoduleFiles
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function removeSubmoduleFiles($submoduleArray) {
//Indicate here any special files we don't want deleted in any repo
$specialFiles = array(".gitignore", ".git");
foreach ($submoduleArray as $submoduleKey => $submoduleValue) {
- 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
Missing class import via use statement (line '45', column '22'). Open
foreach (new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '60', column '20'). Open
$dir = new RecursiveDirectoryIterator($submoduleKey, FilesystemIterator::SKIP_DOTS);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '44', column '20'). Open
$dir = new RecursiveDirectoryIterator($submoduleKey, FilesystemIterator::SKIP_DOTS);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '61', column '22'). Open
foreach (new RecursiveIteratorIterator($dir) as $file) {
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid unused local variables such as '$submoduleValue'. Open
foreach ($submoduleArray as $submoduleKey => $submoduleValue) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 8 and the first side effect is on line 5. Open
<?php
- Exclude checks
Opening brace should be on a new line Open
function removeEmptyDirectories($submoduleArray) {
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if (count(array_diff(scandir($file), array(".", ".."))) == 0){
- Exclude checks
Whitespace found at end of line Open
//Also make the file string work regardless of platform directory separator
- Exclude checks
A closing tag is not permitted at the end of a PHP file Open
?>
- Exclude checks
Opening brace should be on a new line Open
function cleanUpSubmodules() {
- Exclude checks
Opening brace should be on a new line Open
function modifySubmoduleArray($original) {
- Exclude checks
Opening brace should be on a new line Open
function removeSubmoduleFiles($submoduleArray) {
- Exclude checks