dynamic/foxystripe

View on GitHub
src/Model/foxycart.cart_validation.php

Summary

Maintainability
F
3 days
Test Coverage

Function fc_hash_html has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

    public static function fc_hash_html($html)
    {
        // Initialize some counting
        $count['temp'] = 0; // temp counter
        $count['links'] = 0;
Severity: Minor
Found in src/Model/foxycart.cart_validation.php - About 1 day 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 fc_hash_html has 202 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function fc_hash_html($html)
    {
        // Initialize some counting
        $count['temp'] = 0; // temp counter
        $count['links'] = 0;
Severity: Major
Found in src/Model/foxycart.cart_validation.php - About 1 day to fix

File foxycart.cart_validation.php has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use Dynamic\FoxyStripe\Model\FoxyCart;

/**
Severity: Minor
Found in src/Model/foxycart.cart_validation.php - About 3 hrs to fix

Method fc_hash_querystring has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function fc_hash_querystring($qs, $output = true)
    {
        self::$log[] = '<strong>Signing link</strong> with data: '
            .htmlspecialchars(substr($qs, 0, 150)).'...';
        $fail = self::$cart_url.'?'.$qs;
Severity: Major
Found in src/Model/foxycart.cart_validation.php - About 2 hrs to fix

Function fc_hash_querystring has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function fc_hash_querystring($qs, $output = true)
    {
        self::$log[] = '<strong>Signing link</strong> with data: '
            .htmlspecialchars(substr($qs, 0, 150)).'...';
        $fail = self::$cart_url.'?'.$qs;
Severity: Minor
Found in src/Model/foxycart.cart_validation.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

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

    public static function fc_hash_value(
        $product_code,
        $option_name,
        $option_value = '',
        $method = 'name',
Severity: Minor
Found in src/Model/foxycart.cart_validation.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

Method fc_hash_value has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $product_code,
        $option_name,
        $option_value = '',
        $method = 'name',
        $output = true,
Severity: Minor
Found in src/Model/foxycart.cart_validation.php - About 45 mins to fix

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

                        self::$log[] = '<strong>OPTION:</strong> Code: <strong>'.htmlspecialchars($prefix.$code).
                           '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$list[2]).
                           '</strong> :: Value: <strong>'.htmlspecialchars($option[2]).
                           '</strong><br />Initial option: '.htmlspecialchars($option[0]).
                           '<br />Signed: <span style="color:#060;">'.htmlspecialchars($option_signed).'</span>';
Severity: Major
Found in src/Model/foxycart.cart_validation.php and 1 other location - About 1 hr to fix
src/Model/foxycart.cart_validation.php on lines 412..416

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

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

                    self::$log[] = '<strong>TEXTAREA:</strong> Code: <strong>'.htmlspecialchars($prefix.$code).
                       '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$textarea[2]).
                       '</strong> :: Value: <strong>'.htmlspecialchars($textarea[3]).
                       '</strong><br />Initial textarea: '.htmlspecialchars($textarea[0]).
                       '<br />Signed: <span style="color:#060;">'.htmlspecialchars($textarea_signed).'</span>';
Severity: Major
Found in src/Model/foxycart.cart_validation.php and 1 other location - About 1 hr to fix
src/Model/foxycart.cart_validation.php on lines 378..382

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

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