APO-Epsilon/apo-website

View on GitHub
includes/clean_up_submodules.php

Summary

Maintainability
A
1 hr
Test Coverage

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);
Severity: Minor
Found in includes/clean_up_submodules.php by phpmd

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()) {
Severity: Minor
Found in includes/clean_up_submodules.php - About 1 hr 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 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) {
Severity: Minor
Found in includes/clean_up_submodules.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

Missing class import via use statement (line '45', column '22').
Open

        foreach (new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
Severity: Minor
Found in includes/clean_up_submodules.php by phpmd

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);
Severity: Minor
Found in includes/clean_up_submodules.php by phpmd

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);
Severity: Minor
Found in includes/clean_up_submodules.php by phpmd

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) {
Severity: Minor
Found in includes/clean_up_submodules.php by phpmd

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) {
Severity: Minor
Found in includes/clean_up_submodules.php by phpmd

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

Opening brace should be on a new line
Open

function removeEmptyDirectories($submoduleArray) {

Expected 1 space after closing parenthesis; found 0
Open

                if (count(array_diff(scandir($file), array(".", ".."))) == 0){

Whitespace found at end of line
Open

    //Also make the file string work regardless of platform directory separator 

A closing tag is not permitted at the end of a PHP file
Open

?>

Opening brace should be on a new line
Open

function cleanUpSubmodules() {

Opening brace should be on a new line
Open

function modifySubmoduleArray($original) {

Opening brace should be on a new line
Open

function removeSubmoduleFiles($submoduleArray) {

There are no issues that match your filters.

Category
Status