MPOS/php-mpos

View on GitHub
include/smarty/libs/sysplugins/smarty_security.php

Summary

Maintainability
D
1 day
Test Coverage

Function isTrustedResourceDir has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function isTrustedResourceDir($filepath)
    {
        $_template = false;
        $_config = false;
        $_secure = false;
Severity: Minor
Found in include/smarty/libs/sysplugins/smarty_security.php - About 2 hrs 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 isTrustedResourceDir has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function isTrustedResourceDir($filepath)
    {
        $_template = false;
        $_config = false;
        $_secure = false;
Severity: Minor
Found in include/smarty/libs/sysplugins/smarty_security.php - About 2 hrs to fix

    Function isTrustedPHPDir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function isTrustedPHPDir($filepath)
        {
            if (empty($this->trusted_dir)) {
                throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)");
            }
    Severity: Minor
    Found in include/smarty/libs/sysplugins/smarty_security.php - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method isTrustedPHPDir has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function isTrustedPHPDir($filepath)
        {
            if (empty($this->trusted_dir)) {
                throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)");
            }
    Severity: Minor
    Found in include/smarty/libs/sysplugins/smarty_security.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if ((!$this->_template_dir || $this->_template_dir !== $_template_dir)
                      || (!$this->_config_dir || $this->_config_dir !== $_config_dir)
                      || (!empty($this->secure_dir) && (!$this->_secure_dir || $this->_secure_dir !== $this->secure_dir))
              ) {
                  $this->_resource_dir = array();
      Severity: Major
      Found in include/smarty/libs/sysplugins/smarty_security.php - About 1 hr to fix

        Function isTrustedTag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function isTrustedTag($tag_name, $compiler)
            {
                // check for internal always required tags
                if (in_array($tag_name, array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', 'private_object_block_function',
                            'private_object_function', 'private_registered_function', 'private_registered_block', 'private_special_variable', 'private_print_expression', 'private_modifier'))) {
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_security.php - About 55 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

        Function isTrustedModifier has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function isTrustedModifier($modifier_name, $compiler)
            {
                // check for internal always allowed modifier
                if (in_array($modifier_name, array('default'))) {
                    return true;
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_security.php - About 55 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

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

            public function isTrustedUri($uri)
            {
                $_uri = parse_url($uri);
                if (!empty($_uri['scheme']) && !empty($_uri['host'])) {
                    $_uri = $_uri['scheme'] . '://' . $_uri['host'];
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_security.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

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

                if (empty($this->allowed_modifiers)) {
                    if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) {
                        return true;
                    } else {
                        $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", $compiler->lex->taglineno);
        Severity: Major
        Found in include/smarty/libs/sysplugins/smarty_security.php and 1 other location - About 2 hrs to fix
        include/smarty/libs/sysplugins/smarty_security.php on lines 249..259

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

        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 (empty($this->allowed_tags)) {
                    if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) {
                        return true;
                    } else {
                        $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", $compiler->lex->taglineno);
        Severity: Major
        Found in include/smarty/libs/sysplugins/smarty_security.php and 1 other location - About 2 hrs to fix
        include/smarty/libs/sysplugins/smarty_security.php on lines 279..289

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

        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

        There are no issues that match your filters.

        Category
        Status