midasplatform/Midas

View on GitHub
core/controllers/ShareController.php

Summary

Maintainability
F
4 days
Test Coverage

Function dialogAction has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
Open

    public function dialogAction()
    {
        $this->disableLayout();
        $type = $this->getParam('type');
        $element = $this->getParam('element');
Severity: Minor
Found in core/controllers/ShareController.php - About 2 days 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

Method dialogAction has 195 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function dialogAction()
    {
        $this->disableLayout();
        $type = $this->getParam('type');
        $element = $this->getParam('element');
Severity: Major
Found in core/controllers/ShareController.php - About 7 hrs to fix

File ShareController.php has 277 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 core/controllers/ShareController.php - About 2 hrs to fix

Method linksAction has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function linksAction()
    {
        $this->disableLayout();
        $type = $this->getParam('type');
        $id = $this->getParam('id');
Severity: Minor
Found in core/controllers/ShareController.php - About 1 hr to fix

Function linksAction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function linksAction()
    {
        $this->disableLayout();
        $type = $this->getParam('type');
        $id = $this->getParam('id');
Severity: Minor
Found in core/controllers/ShareController.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

Avoid too many return statements within this method.
Open

                return;
Severity: Major
Found in core/controllers/ShareController.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return;
Severity: Major
Found in core/controllers/ShareController.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return;
Severity: Major
Found in core/controllers/ShareController.php - About 30 mins to fix

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

    public function dialogAction()
    {
        $this->disableLayout();
        $type = $this->getParam('type');
        $element = $this->getParam('element');
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

The method dialogAction() has an NPath complexity of 51861888. The configured NPath complexity threshold is 200.
Open

    public function dialogAction()
    {
        $this->disableLayout();
        $type = $this->getParam('type');
        $element = $this->getParam('element');
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method dialogAction() has a Cyclomatic Complexity of 38. The configured cyclomatic complexity threshold is 10.
Open

    public function dialogAction()
    {
        $this->disableLayout();
        $type = $this->getParam('type');
        $element = $this->getParam('element');
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

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

            throw new Zend_Exception('Admin privileges required to change permissions');
Severity: Minor
Found in core/controllers/ShareController.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 '58', column '27').
Open

                throw new Zend_Exception('Unknown type, expected folder or item.');
Severity: Minor
Found in core/controllers/ShareController.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 '300', column '26').
Open

        $validator = new Zend_Validate_Digits();
Severity: Minor
Found in core/controllers/ShareController.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 '63', column '23').
Open

            throw new Zend_Exception('Unable to load element.');
Severity: Minor
Found in core/controllers/ShareController.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 '302', column '23').
Open

            throw new Zend_Exception('Must specify an id parameter');
Severity: Minor
Found in core/controllers/ShareController.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 '321', column '27').
Open

                throw new Zend_Exception('Invalid type', 400);
Severity: Minor
Found in core/controllers/ShareController.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 '47', column '23').
Open

            throw new Zend_Exception('Parameters problem, expecting type or element to be set.');
Severity: Minor
Found in core/controllers/ShareController.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 using static access to class 'JsonComponent' in method 'applyrecursivedialogAction'.
Open

            echo JsonComponent::encode(array(true, $results));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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 'JsonComponent' in method 'dialogAction'.
Open

        $this->view->jsonShare = JsonComponent::encode($this->view->jsonShare);
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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

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

                } else {
                    $changePolicy = $this->User->load($changeId);
                }
Severity: Minor
Found in core/controllers/ShareController.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

Avoid using static access to class 'JsonComponent' in method 'dialogAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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

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

                    } else {
                        $policyDao = $this->Itempolicyuser->getPolicy($changePolicy, $element);
                        $this->Itempolicyuser->delete($policyDao);
                        $policyDao->setPolicy($changeVal);
                        $this->Itempolicyuser->save($policyDao);
Severity: Minor
Found in core/controllers/ShareController.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

Avoid using static access to class 'JsonComponent' in method 'dialogAction'.
Open

                        echo JsonComponent::encode(array(false, $this->t('Error')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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

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

                } else {
                    if ($newPolicy instanceof GroupDao) {
                        $this->Itempolicygroup->createPolicy($newPolicy, $element, MIDAS_POLICY_READ);
                    } elseif ($newPolicy instanceof UserDao) {
                        $this->Itempolicyuser->createPolicy($newPolicy, $element, MIDAS_POLICY_READ);
Severity: Minor
Found in core/controllers/ShareController.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

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

        } else {
            $groupPolicies = $element->getItempolicygroup();
            $userPolicies = $element->getItempolicyuser();
        }
Severity: Minor
Found in core/controllers/ShareController.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

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

        } else {
            $isAdmin = $this->Item->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
        }
Severity: Minor
Found in core/controllers/ShareController.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

Avoid using static access to class 'JsonComponent' in method 'dialogAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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 'JsonComponent' in method 'applyrecursivedialogAction'.
Open

                echo JsonComponent::encode(array(false, $this->t('Invalid folder id')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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 'JsonComponent' in method 'dialogAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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 'JsonComponent' in method 'dialogAction'.
Open

                        echo JsonComponent::encode(array(false, $this->t('Error')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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

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

                } else {
                    if ($removeType == 'group') {
                        $policyDao = $this->Itempolicygroup->getPolicy($removePolicy, $element);
                        $this->Itempolicygroup->delete($policyDao);
                    } else {
Severity: Minor
Found in core/controllers/ShareController.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

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

                    } else {
                        $policyDao = $this->Folderpolicyuser->getPolicy($changePolicy, $element);
                        $this->Folderpolicyuser->delete($policyDao);
                        $policyDao->setPolicy($changeVal);
                        $this->Folderpolicyuser->save($policyDao);
Severity: Minor
Found in core/controllers/ShareController.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

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

                    } else {
                        echo JsonComponent::encode(array(false, $this->t('Error')));

                        return;
                    }
Severity: Minor
Found in core/controllers/ShareController.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

Avoid using static access to class 'JsonComponent' in method 'dialogAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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

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

                    } else {
                        echo JsonComponent::encode(array(false, $this->t('Error')));

                        return;
                    }
Severity: Minor
Found in core/controllers/ShareController.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

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

                } else {
                    $newPolicy = $this->User->load($newPolicyId);
                }
Severity: Minor
Found in core/controllers/ShareController.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

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

                } else {
                    $removePolicy = $this->User->load($removeId);
                }
Severity: Minor
Found in core/controllers/ShareController.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

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

                    } else {
                        $policyDao = $this->Itempolicyuser->getPolicy($removePolicy, $element);
                        $this->Itempolicyuser->delete($policyDao);
                    }
Severity: Minor
Found in core/controllers/ShareController.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

Avoid using static access to class 'JsonComponent' in method 'dialogAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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

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

                } else {
                    $this->Itempolicygroup->createPolicy($anonymousGroup, $element, MIDAS_POLICY_READ);
                }
Severity: Minor
Found in core/controllers/ShareController.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

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

        } else {
            $this->view->downloadUrl = $baseUrl.'/download/'.$type.'/'.$id.'/'.urlencode($name);
        }
Severity: Minor
Found in core/controllers/ShareController.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

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

                } else {
                    $policyDao = $this->Itempolicygroup->getPolicy($anonymousGroup, $element);
                    $this->Itempolicygroup->delete($policyDao);
                }
Severity: Minor
Found in core/controllers/ShareController.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

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

                } else {
                    if ($changeType == 'group') {
                        $policyDao = $this->Itempolicygroup->getPolicy($changePolicy, $element);
                        $this->Itempolicygroup->delete($policyDao);
                        $policyDao->setPolicy($changeVal);
Severity: Minor
Found in core/controllers/ShareController.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

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

                    } else {
                        $policyDao = $this->Folderpolicyuser->getPolicy($removePolicy, $element);
                        $this->Folderpolicyuser->delete($policyDao);
                    }
Severity: Minor
Found in core/controllers/ShareController.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

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

                } else {
                    if ($changeType == 'group') {
                        $policyDao = $this->Itempolicygroup->getPolicy($changePolicy, $element);
                        $this->Itempolicygroup->delete($policyDao);
                        $policyDao->setPolicy($changeVal);
Severity: Major
Found in core/controllers/ShareController.php and 1 other location - About 1 hr to fix
core/controllers/ShareController.php on lines 92..116

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

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

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

                if ($type == 'folder') {
                    if ($changeType == 'group') {
                        $policyDao = $this->Folderpolicygroup->getPolicy($changePolicy, $element);
                        $this->Folderpolicygroup->delete($policyDao);
                        $policyDao->setPolicy($changeVal);
Severity: Major
Found in core/controllers/ShareController.php and 1 other location - About 1 hr to fix
core/controllers/ShareController.php on lines 104..116

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

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

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

                } else {
                    if ($newPolicy instanceof GroupDao) {
                        $this->Itempolicygroup->createPolicy($newPolicy, $element, MIDAS_POLICY_READ);
                    } elseif ($newPolicy instanceof UserDao) {
                        $this->Itempolicyuser->createPolicy($newPolicy, $element, MIDAS_POLICY_READ);
Severity: Minor
Found in core/controllers/ShareController.php and 1 other location - About 30 mins to fix
core/controllers/ShareController.php on lines 162..182

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

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

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

                if ($type == 'folder') {
                    if ($newPolicy instanceof GroupDao) {
                        $this->Folderpolicygroup->createPolicy($newPolicy, $element, MIDAS_POLICY_READ);
                    } elseif ($newPolicy instanceof UserDao) {
                        $this->Folderpolicyuser->createPolicy($newPolicy, $element, MIDAS_POLICY_READ);
Severity: Minor
Found in core/controllers/ShareController.php and 1 other location - About 30 mins to fix
core/controllers/ShareController.php on lines 172..182

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

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 ShareController extends AppController

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

        $id = $this->getParam('id');
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

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

The property $_components is not named in camelCase.
Open

class ShareController extends AppController
{
    public $_models = array(
        'Item',
        'Folder',
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_forms is not named in camelCase.
Open

class ShareController extends AppController
{
    public $_models = array(
        'Item',
        'Folder',
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_daos is not named in camelCase.
Open

class ShareController extends AppController
{
    public $_models = array(
        'Item',
        'Folder',
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $_models is not named in camelCase.
Open

class ShareController extends AppController
{
    public $_models = array(
        'Item',
        'Folder',
Severity: Minor
Found in core/controllers/ShareController.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

Property name "$_components" should not be prefixed with an underscore to indicate visibility
Open

    public $_components = array('Policy');

Property name "$_daos" should not be prefixed with an underscore to indicate visibility
Open

    public $_daos = array();

Property name "$_forms" should not be prefixed with an underscore to indicate visibility
Open

    public $_forms = array();

Property name "$_models" should not be prefixed with an underscore to indicate visibility
Open

    public $_models = array(

Only one argument is allowed per line in a multi-line function call
Open

            $results = $this->Component->Policy->applyPoliciesRecursive($folder, $this->userSession->Dao,

Closing parenthesis of a multi-line function call must be on a line by itself
Open

                $this->progressDao);

Multi-line function call not indented correctly; expected 12 spaces but found 20
Open

                    'Moderators group of community') != false

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                $this->progressDao);

Opening parenthesis of a multi-line function call must be the last content on the line
Open

            if (strpos($group->getName(), 'Admin group of community') != false || strpos($group->getName(),

Opening parenthesis of a multi-line function call must be the last content on the line
Open

            $results = $this->Component->Policy->applyPoliciesRecursive($folder, $this->userSession->Dao,

Closing parenthesis of a multi-line function call must be on a line by itself
Open

                    'Moderators group of community') != false

There are no issues that match your filters.

Category
Status