midasplatform/Midas

View on GitHub
modules/validation/tests/models/base/DashboardModelTest.php

Summary

Maintainability
F
1 wk
Test Coverage

File DashboardModelTest.php has 432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*=========================================================================
 Midas Server
 Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
 All rights reserved.
Severity: Minor
Found in modules/validation/tests/models/base/DashboardModelTest.php - About 6 hrs to fix

Method testGetAllScores has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testGetAllScores()
    {
        // Create training, testing, and truth folders
        $testingFolder = new FolderDao();
        $testingFolder->setName('testing');
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php - About 3 hrs to fix

Method testSetScore has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testSetScore()
    {
        // Create training, testing, and truth folders
        $testingFolder = new FolderDao();
        $testingFolder->setName('testing');
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php - About 2 hrs to fix

Method testSetScores has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testSetScores()
    {
        // Create training, testing, and truth folders
        $testingFolder = new FolderDao();
        $testingFolder->setName('testing');
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php - About 2 hrs to fix

Method testAddRemoveResult has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testAddRemoveResult()
    {
        // Create training, testing, and truth folders
        $testingFolder = new FolderDao();
        $testingFolder->setName('testing');
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php - About 2 hrs to fix

Method testVerifyConsistency has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testVerifyConsistency()
    {
        // Create training, testing, and truth folders
        $testingFolder = new FolderDao();
        $testingFolder->setName('testing');
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php - About 2 hrs to fix

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

    public function testGetAllScores()
    {
        // Create training, testing, and truth folders
        $testingFolder = new FolderDao();
        $testingFolder->setName('testing');
Severity: Minor
Found in modules/validation/tests/models/base/DashboardModelTest.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

The method testGetAllScores() has 120 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function testGetAllScores()
    {
        // Create training, testing, and truth folders
        $testingFolder = new FolderDao();
        $testingFolder->setName('testing');

Missing class import via use statement (line '187', column '28').
Open

        $truthFolder = new FolderDao();

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 '272', column '31').
Open

        $trainingFolder = new FolderDao();

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 '177', column '30').
Open

        $testingFolder = new FolderDao();

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 '194', column '29').
Open

        $resultFolder = new FolderDao();

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 '267', column '30').
Open

        $testingFolder = new FolderDao();

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 '383', column '29').
Open

        $resultFolder = new FolderDao();

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 '519', column '33').
Open

            $trainingItem = new ItemDao();

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 '121', column '30').
Open

            $truthItem = new ItemDao();

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 '299', column '31').
Open

            $resultItem = new ItemDao();

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 '208', column '30').
Open

            $truthItem = new ItemDao();

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 '395', column '33').
Open

            $trainingItem = new ItemDao();

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 '277', column '28').
Open

        $truthFolder = new FolderDao();

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 '521', column '30').
Open

            $truthItem = new ItemDao();

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 '397', column '30').
Open

            $truthItem = new ItemDao();

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 '500', column '28').
Open

        $truthFolder = new FolderDao();

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 '209', column '31').
Open

            $resultItem = new ItemDao();

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 '296', column '33').
Open

            $trainingItem = new ItemDao();

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 '396', column '32').
Open

            $testingItem = new ItemDao();

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 '298', column '30').
Open

            $truthItem = new ItemDao();

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 '98', column '30').
Open

        $testingFolder = new FolderDao();

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 '119', column '33').
Open

            $trainingItem = new ItemDao();

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 '120', column '32').
Open

            $testingItem = new ItemDao();

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 '182', column '31').
Open

        $trainingFolder = new FolderDao();

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 '284', column '29').
Open

        $resultFolder = new FolderDao();

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 '376', column '28').
Open

        $truthFolder = new FolderDao();

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 '366', column '30').
Open

        $testingFolder = new FolderDao();

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 '206', column '33').
Open

            $trainingItem = new ItemDao();

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 '495', column '31').
Open

        $trainingFolder = new FolderDao();

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 '522', column '31').
Open

            $resultItem = new ItemDao();

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 '297', column '32').
Open

            $testingItem = new ItemDao();

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 '371', column '31').
Open

        $trainingFolder = new FolderDao();

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 '398', column '31').
Open

            $resultItem = new ItemDao();

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 '490', column '30').
Open

        $testingFolder = new FolderDao();

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 '520', column '32').
Open

            $testingItem = new ItemDao();

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 '507', column '29').
Open

        $resultFolder = new FolderDao();

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 '103', column '31').
Open

        $trainingFolder = new FolderDao();

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 '108', column '28').
Open

        $truthFolder = new FolderDao();

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 '49', column '44').
Open

        Zend_Registry::set('notifier', new MIDAS_Notifier(false, null));

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 '207', column '32').
Open

            $testingItem = new ItemDao();

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 'testVerifyConsistency'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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 'testSetScores'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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 'Zend_Registry' in method 'setUp'.
Open

        $db = Zend_Registry::get('dbAdapter');

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 'testAddRemoveResult'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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 'Zend_Registry' in method 'setUp'.
Open

        Zend_Registry::set('notifier', new MIDAS_Notifier(false, null));

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 'Zend_Registry' in method 'setUp'.
Open

        $configDatabase = Zend_Registry::get('configDatabase');

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 'Zend_Registry' in method 'setUp'.
Open

        Zend_Registry::set('modulesEnable', array());

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 'testSetScore'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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 'testGetTestingTrainingAndTruth'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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 'testGetAllScores'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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 'testGetAll'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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 'testGetResults'.
Open

        $dashboardModel = MidasLoader::loadModel('Dashboard', 'validation');

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

        for ($i = 0; $i < 3; ++$i) {
            $trainingItem = new ItemDao();
            $testingItem = new ItemDao();
            $truthItem = new ItemDao();
            $resultItem = new ItemDao();
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php and 3 other locations - About 1 day to fix
modules/validation/tests/models/base/DashboardModelTest.php on lines 205..235
modules/validation/tests/models/base/DashboardModelTest.php on lines 295..325
modules/validation/tests/models/base/DashboardModelTest.php on lines 394..424

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 318.

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

        for ($i = 0; $i < 3; ++$i) {
            $trainingItem = new ItemDao();
            $testingItem = new ItemDao();
            $truthItem = new ItemDao();
            $resultItem = new ItemDao();
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php and 3 other locations - About 1 day to fix
modules/validation/tests/models/base/DashboardModelTest.php on lines 205..235
modules/validation/tests/models/base/DashboardModelTest.php on lines 394..424
modules/validation/tests/models/base/DashboardModelTest.php on lines 518..548

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 318.

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

        for ($i = 0; $i < 3; ++$i) {
            $trainingItem = new ItemDao();
            $testingItem = new ItemDao();
            $truthItem = new ItemDao();
            $resultItem = new ItemDao();
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php and 3 other locations - About 1 day to fix
modules/validation/tests/models/base/DashboardModelTest.php on lines 205..235
modules/validation/tests/models/base/DashboardModelTest.php on lines 295..325
modules/validation/tests/models/base/DashboardModelTest.php on lines 518..548

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 318.

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

        for ($i = 0; $i < 3; ++$i) {
            $trainingItem = new ItemDao();
            $testingItem = new ItemDao();
            $truthItem = new ItemDao();
            $resultItem = new ItemDao();
Severity: Major
Found in modules/validation/tests/models/base/DashboardModelTest.php and 3 other locations - About 1 day to fix
modules/validation/tests/models/base/DashboardModelTest.php on lines 295..325
modules/validation/tests/models/base/DashboardModelTest.php on lines 394..424
modules/validation/tests/models/base/DashboardModelTest.php on lines 518..548

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 318.

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 Validation_DashboardModelTest extends DatabaseTestCase

The class Validation_DashboardModelTest is not named in CamelCase.
Open

class Validation_DashboardModelTest extends DatabaseTestCase
{
    /** set up tests */
    public function setUp()
    {

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = Zend_Registry::get('dbAdapter');

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Line exceeds 120 characters; contains 141 characters
Open

                "SELECT setval('validation_scalarresult_scalarresult_id_seq', (SELECT MAX(scalarresult_id) FROM validation_scalarresult)+1);"

Line exceeds 120 characters; contains 129 characters
Open

                "SELECT setval('validation_dashboard_dashboard_id_seq', (SELECT MAX(dashboard_id) FROM validation_dashboard)+1);"

Line exceeds 120 characters; contains 182 characters
Open

                "SELECT setval('validation_dashboard2scalarresult_dashboard2scalarresult_id_seq', (SELECT MAX(dashboard2scalarresult_id) FROM  validation_dashboard2scalarresult)+1);"

Line exceeds 120 characters; contains 157 characters
Open

                "SELECT setval('validation_dashboard2folder_dashboard2folder_id_seq', (SELECT MAX(dashboard2folder_id) FROM validation_dashboard2folder)+1);"

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

class Validation_DashboardModelTest extends DatabaseTestCase

There are no issues that match your filters.

Category
Status