MPOS/php-mpos

View on GitHub

Showing 1,089 of 1,089 total issues

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

Block has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class Block extends Base {
  protected $table = 'blocks';

  /**
   * Specific method to fetch the latest block found
Severity: Minor
Found in include/classes/block.class.php - About 2 hrs to fix

    Method __construct has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct(Smarty_Internal_Template $_template)
        {
            $this->compile_id = $_template->compile_id;
            $this->cache_id = $_template->cache_id;
            $this->source = $_template->source;
    Severity: Major
    Found in include/smarty/libs/sysplugins/smarty_cacheresource.php - About 2 hrs to fix

      Method yy_is_expected_token has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function yy_is_expected_token($token)
          {
              if ($token === 0) {
                  return true; // 0 is not part of this
              }
      Severity: Major
      Found in include/smarty/libs/sysplugins/smarty_internal_templateparser.php - About 2 hrs to fix

        Method yy_is_expected_token has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function yy_is_expected_token($token)
            {
                if ($token === 0) {
                    return true; // 0 is not part of this
                }
        Severity: Major
        Found in include/smarty/libs/sysplugins/smarty_internal_configfileparser.php - About 2 hrs to fix

          Method getPrice has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public function getPrice() {
              $aData = $this->getApi($this->config['price']['url'], $this->config['price']['target']);
              $strBase = $this->config['currency'];
              $strQuote = $this->config['price']['currency'];
              // Check the API type for configured URL
          Severity: Major
          Found in include/classes/tools.class.php - About 2 hrs to fix

            Method __construct has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public function __construct($config, &$memcache, $request='') {
                $this->cache = $memcache;
                // set our config options
                $userORip = $_SERVER['REMOTE_ADDR'].@$_SERVER['HTTP_USER_AGENT'];
                // prep stuff we need to check this request
            Severity: Major
            Found in include/classes/memcache_ad.class.php - About 2 hrs to fix

              Method streamToMime has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message)
                  {
                      $bufferLength = 78;
                      $headerData = '';
              
              
              Severity: Major
              Found in include/lib/swiftmailer/classes/Swift/Signers/SMimeSigner.php - About 2 hrs to fix

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

                    function yy_r5_2($yy_subpatterns)
                    {
                
                  if ($this->smarty->auto_literal && ($this->mbstring_overload ? (mb_strpos(" \n\t\r",mb_substr($this->value,$this->ldel_length,1,'latin1'),0,'latin1') !== false) : (strpos(" \n\t\r",substr($this->value,$this->ldel_length,1)) !== false))) {
                     return false;
                include/smarty/libs/sysplugins/smarty_internal_templatelexer.php on lines 1236..1244

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

                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

                    function yy_r5_1($yy_subpatterns)
                    {
                
                  if ($this->smarty->auto_literal && ($this->mbstring_overload ? (mb_strpos(" \n\t\r",mb_substr($this->value,$this->ldel_length,1,'latin1'),0,'latin1') !== false) : (strpos(" \n\t\r",substr($this->value,$this->ldel_length,1)) !== false))) {
                     return false;
                include/smarty/libs/sysplugins/smarty_internal_templatelexer.php on lines 1245..1253

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

                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

                Function smarty_modifier_date_format has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                function smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto')
                {
                    if ($format === null) {
                        $format = Smarty::$_DATE_FORMAT;
                    }
                Severity: Minor
                Found in include/smarty/libs/plugins/modifier.date_format.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

                Function run_0010 has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                function run_0010() {
                  // Ugly but haven't found a better way
                  global $setting, $config, $statistics, $block, $mysqli;
                
                  // Version information
                Severity: Minor
                Found in upgrade/definitions/0.0.9_to_0.0.10.inc.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

                Function smarty_modifier_truncate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
                {
                    if ($length == 0)
                        return '';
                
                
                Severity: Minor
                Found in include/smarty/libs/plugins/modifier.truncate.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

                Function compile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function compile($args, $compiler, $parameter)
                    {
                        $_index = preg_split("/\]\[/",substr($parameter, 1, strlen($parameter)-2));
                        $compiled_ref = ' ';
                        $variable = trim($_index[0], "'");

                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 compile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function compile($args, $compiler, $parameter, $tag, $method)
                    {
                        // check and get attributes
                        $_attr = $this->getAttributes($compiler, $args);
                        if ($_attr['nocache'] === true) {

                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 yy_get_expected_tokens has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function yy_get_expected_tokens($token)
                    {
                        $state = $this->yystack[$this->yyidx]->stateno;
                        $expected = self::$yyExpectedTokens[$state];
                        if (in_array($token, self::$yyExpectedTokens[$state], true)) {
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_configfileparser.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

                Function yylex1 has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function yylex1()
                    {
                        $tokenMap = array (
                              1 => 0,
                              2 => 1,
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_templatelexer.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

                Function yylex5 has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function yylex5()
                    {
                        $tokenMap = array (
                              1 => 0,
                              2 => 0,
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_templatelexer.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

                Function yy_get_expected_tokens has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function yy_get_expected_tokens($token)
                    {
                        $state = $this->yystack[$this->yyidx]->stateno;
                        $expected = self::$yyExpectedTokens[$state];
                        if (in_array($token, self::$yyExpectedTokens[$state], true)) {
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_templateparser.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

                Function yylex2 has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function yylex2()
                    {
                        $tokenMap = array (
                              1 => 0,
                              2 => 0,
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_templatelexer.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

                Severity
                Category
                Status
                Source
                Language