PressLabs/gitium

View on GitHub
gitium/inc/class-gitium-admin.php

Summary

Maintainability
A
25 mins
Test Coverage

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

    public function __construct() {
        global $git;

        list( , $git_private_key ) = gitium_get_keypair();
        $git->set_key( $git_private_key );
Severity: Minor
Found in gitium/inc/class-gitium-admin.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

Missing class import via use statement (line '51', column '7').
Open

        new Gitium_Admin();
Severity: Minor
Found in gitium/inc/class-gitium-admin.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 '34', column '9').
Open

                new Gitium_Submenu_Commits();
Severity: Minor
Found in gitium/inc/class-gitium-admin.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 '33', column '9').
Open

                new Gitium_Submenu_Status();
Severity: Minor
Found in gitium/inc/class-gitium-admin.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 '35', column '9').
Open

                new Gitium_Submenu_Settings();
Severity: Minor
Found in gitium/inc/class-gitium-admin.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 '27', column '15').
Open

            $req = new Gitium_Requirements();
Severity: Minor
Found in gitium/inc/class-gitium-admin.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 '36', column '9').
Open

                new Gitium_Menu_Bubble();
Severity: Minor
Found in gitium/inc/class-gitium-admin.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 '38', column '9').
Open

                new Gitium_Submenu_Configure();
Severity: Minor
Found in gitium/inc/class-gitium-admin.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

The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                new Gitium_Submenu_Configure();
            }
Severity: Minor
Found in gitium/inc/class-gitium-admin.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Gitium_Admin {

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 18 and the first side effect is on line 49.
Open

<?php

The class Gitium_Admin is not named in CamelCase.
Open

class Gitium_Admin {

    public function __construct() {
        global $git;

Severity: Minor
Found in gitium/inc/class-gitium-admin.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Method name "Gitium_Admin::has_configuration" is not in camel caps format
Open

    public function has_configuration() {

Expected 0 spaces before closing bracket; 1 found
Open

if ( ( is_admin() && ! is_multisite() ) || ( is_network_admin() && is_multisite() ) ) {

Expected 0 spaces before closing bracket; 1 found
Open

            if ( $this->has_configuration() ) {

Expected 0 spaces before closing bracket; 1 found
Open

            if ( ! $req->get_status() ) {

Expected 0 spaces before closing bracket; 1 found
Open

        if ( current_user_can( GITIUM_MANAGE_OPTIONS_CAPABILITY ) ) {

Opening brace of a class must be on the line after the definition
Open

class Gitium_Admin {

Spaces must be used to indent lines; tabs are not allowed
Open

                new Gitium_Menu_Bubble();

Spaces must be used to indent lines; tabs are not allowed
Open

                return false;

Spaces must be used to indent lines; tabs are not allowed
Open

        $git->set_key( $git_private_key );

Spaces must be used to indent lines; tabs are not allowed
Open

            if ( ! $req->get_status() ) {

Spaces must be used to indent lines; tabs are not allowed
Open

    add_action( 'init', 'gitium_admin_page' );

Spaces must be used to indent lines; tabs are not allowed
Open

        global $git;

Spaces must be used to indent lines; tabs are not allowed
Open

            $req = new Gitium_Requirements();

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

                new Gitium_Submenu_Settings();

Spaces must be used to indent lines; tabs are not allowed
Open

        list( , $git_private_key ) = gitium_get_keypair();

Spaces must be used to indent lines; tabs are not allowed
Open

        if ( current_user_can( GITIUM_MANAGE_OPTIONS_CAPABILITY ) ) {

Spaces must be used to indent lines; tabs are not allowed
Open

        return _gitium_is_status_working() && _gitium_get_remote_tracking_branch();

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    function gitium_admin_page() {

Spaces must be used to indent lines; tabs are not allowed
Open

    public function has_configuration() {

Spaces must be used to indent lines; tabs are not allowed
Open

            if ( $this->has_configuration() ) {

Spaces must be used to indent lines; tabs are not allowed
Open

        new Gitium_Admin();

Spaces must be used to indent lines; tabs are not allowed
Open

                new Gitium_Submenu_Status();

Spaces must be used to indent lines; tabs are not allowed
Open

                new Gitium_Submenu_Commits();

Spaces must be used to indent lines; tabs are not allowed
Open

            } else {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function __construct() {

Spaces must be used to indent lines; tabs are not allowed
Open

                new Gitium_Submenu_Configure();

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Space after opening parenthesis of function call prohibited
Open

        $git->set_key( $git_private_key );

Opening brace should be on a new line
Open

    function gitium_admin_page() {

Expected 0 spaces after opening bracket; 1 found
Open

        if ( current_user_can( GITIUM_MANAGE_OPTIONS_CAPABILITY ) ) {

Opening brace should be on a new line
Open

    public function has_configuration() {

Space after opening parenthesis of function call prohibited
Open

    add_action( 'init', 'gitium_admin_page' );

Expected 0 spaces before closing bracket; 1 found
Open

        if ( current_user_can( GITIUM_MANAGE_OPTIONS_CAPABILITY ) ) {

Space after opening parenthesis of function call prohibited
Open

        if ( current_user_can( GITIUM_MANAGE_OPTIONS_CAPABILITY ) ) {

Expected 0 spaces after opening bracket; 1 found
Open

            if ( ! $req->get_status() ) {

Expected 0 spaces before closing bracket; 1 found
Open

        $git->set_key( $git_private_key );

Expected 0 spaces after opening bracket; 1 found
Open

            if ( $this->has_configuration() ) {

Expected 0 spaces after opening bracket; 1 found
Open

if ( ( is_admin() && ! is_multisite() ) || ( is_network_admin() && is_multisite() ) ) {

Opening brace should be on a new line
Open

    public function __construct() {

Class name "Gitium_Admin" is not in camel caps format
Open

class Gitium_Admin {

Expected 0 spaces before closing bracket; 1 found
Open

    add_action( 'init', 'gitium_admin_page' );

The variable $git_private_key is not named in camelCase.
Open

    public function __construct() {
        global $git;

        list( , $git_private_key ) = gitium_get_keypair();
        $git->set_key( $git_private_key );
Severity: Minor
Found in gitium/inc/class-gitium-admin.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $git_private_key is not named in camelCase.
Open

    public function __construct() {
        global $git;

        list( , $git_private_key ) = gitium_get_keypair();
        $git->set_key( $git_private_key );
Severity: Minor
Found in gitium/inc/class-gitium-admin.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method has_configuration is not named in camelCase.
Open

    public function has_configuration() {
        return _gitium_is_status_working() && _gitium_get_remote_tracking_branch();
    }
Severity: Minor
Found in gitium/inc/class-gitium-admin.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status