midasplatform/Midas

View on GitHub
modules/tracker/controllers/components/ApiscalarComponent.php

Summary

Maintainability
F
4 days
Test Coverage

Missing class import via use statement (line '55', column '23').
Open

            throw new Exception('The scalar does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

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 '90', column '23').
Open

            throw new Exception('The scalar does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

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 '197', column '23').
Open

            throw new Exception('The scalar does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

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 '149', column '23').
Open

            throw new Exception('The trend does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

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 using static access to class 'MidasLoader' in method 'post'.
Open

        $scalarModel = MidasLoader::loadModel('Scalar', $this->moduleName);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'delete'.
Open

        $scalarModel = MidasLoader::loadModel('Scalar', $this->moduleName);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'delete'.
Open

        $apihelperComponent = MidasLoader::loadComponent('Apihelper');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'put'.
Open

        $apihelperComponent = MidasLoader::loadComponent('Apihelper');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'index'.
Open

        $apihelperComponent = MidasLoader::loadComponent('Apihelper');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'put'.
Open

        $scalarModel = MidasLoader::loadModel('Scalar', $this->moduleName);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'get'.
Open

        $scalarModel = MidasLoader::loadModel('Scalar', $this->moduleName);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'get'.
Open

        $apihelperComponent = MidasLoader::loadComponent('Apihelper');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'post'.
Open

        $apihelperComponent = MidasLoader::loadComponent('Apihelper');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'MidasLoader' in method 'post'.
Open

        $trendModel = MidasLoader::loadModel('Trend', $this->moduleName);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

TODO found
Open

     * TODO.

TODO found
Open

        // TODO: Implement index().

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php
/*=========================================================================
 Midas Server
 Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
 All rights reserved.
Severity: Major
Found in modules/tracker/controllers/components/ApiscalarComponent.php and 1 other location - About 4 days to fix
modules/tracker/controllers/components/ApitrendComponent.php on lines 1..235

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 882.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

class Tracker_ApiscalarComponent extends AppComponent

The class Tracker_ApiscalarComponent is not named in CamelCase.
Open

class Tracker_ApiscalarComponent extends AppComponent
{
    /** @var string */
    public $moduleName = 'tracker';

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

Method name "_toArray" should not be prefixed with an underscore to indicate visibility
Open

    protected function _toArray($scalarDao)

Line exceeds 120 characters; contains 127 characters
Open

            throw new Exception('The scalar does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

Line exceeds 120 characters; contains 127 characters
Open

            throw new Exception('The scalar does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

Line exceeds 120 characters; contains 126 characters
Open

            throw new Exception('The trend does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

Line exceeds 120 characters; contains 127 characters
Open

            throw new Exception('The scalar does not exist or you do not have the necessary permission', MIDAS_INVALID_POLICY);

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

class Tracker_ApiscalarComponent extends AppComponent

The method _toArray is not named in camelCase.
Open

    protected function _toArray($scalarDao)
    {
        $scalarArray = array(
            '_id' => $scalarDao->getKey(),
            '_type' => 'Tracker_Scalar',

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