bitslip6/bitfire

View on GitHub

Showing 749 of 749 total issues

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

function icontains(string $haystack, $needle) : bool { if(is_array($needle)) { foreach ($needle as $n) { if (!empty($n) && stripos($haystack, $n) !== false) { return true; } } return false; } else { return stripos($haystack, $needle) !== false; } }
Severity: Minor
Found in firewall/src/util.php and 1 other location - About 45 mins to fix
firewall/src/util.php on lines 405..405

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

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 contains(string $haystack, $needle) : bool { if(is_array($needle)) { foreach ($needle as $n) { if (!empty($n) && strpos($haystack, $n) !== false) { return true; } } return false; } else { return strpos($haystack, $needle) !== false; } }
Severity: Minor
Found in firewall/src/util.php and 1 other location - About 45 mins to fix
firewall/src/util.php on lines 406..406

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

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

Consider simplifying this complex logical expression.
Open

        if (($agent->browser == "chrome" && version_compare($agent->ver, "78.0") < 0)
            || ($agent->browser == "edge" && version_compare($agent->ver, "17.0") < 0)
            || ($agent->browser == "explorer") || ($agent->browser == "safari")) {

            $effect->header("X-XSS-Protection", ": 1; mode=block");
Severity: Major
Found in firewall/src/headers.php - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        if (
            ($header['hash1'] === $key_hashes[0] && $header['hash2'] === $key_hashes[1]) ||
            ($header['expires'] < $ctx['now']) ||
            ($priority === CUCKOO_PERM) ||
            ($priority > CUCKOO_LOW && !($header['flags'] & CUCKOO_HIGH))
    Severity: Major
    Found in firewall/src/cuckoo.php - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          if (
              ($header['hash1'] === $key_hashes[0] && $header['hash2'] === $key_hashes[1]) ||
              ($header['expires'] < $ctx['now']) ||
              ($priority === CUCKOO_PERM) ||
              ($priority > CUCKOO_LOW && !($header['flags'] & CUCKOO_HIGH))
      Severity: Major
      Found in firewall/src/cuckoo.php - About 40 mins to fix

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

            $max_len = array_reduce($lines, function ($carry, $x) use (&$line_no, &$max_line) {
                static $ctr = 0;
                $ctr++;
                $len = strlen($x);
                if ($len > $carry) {
        Severity: Minor
        Found in firewall/src/cms.php and 1 other location - About 40 mins to fix
        firewall/src/cms.php on lines 1180..1190

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

        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 2 locations. Consider refactoring.
        Open

            $max_len = array_reduce($lines, function ($carry, $x) use (&$line_no, &$max_line) {
                static $ctr = 0;
                $ctr++;
                $len = strlen($x);
                if ($len > $carry) {
        Severity: Minor
        Found in firewall/src/cms.php and 1 other location - About 40 mins to fix
        firewall/src/cms.php on lines 1076..1086

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

        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

        Method http_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function http_response(string $content, string $url, array $headers, int $len, bool $success) : HttpResponse {
        Severity: Minor
        Found in firewall/src/http.php - About 35 mins to fix

          Method insert_stmt has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              protected function insert_stmt(string $table, array $data, int $on_duplicate = DB_DUPLICATE_IGNORE, ?array $no_update = null, ?array $if_null = null) : string {
          Severity: Minor
          Found in firewall/src/db.php - About 35 mins to fix

            Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function __construct(string $content, string $url, array $headers, int $len, bool $success)
            Severity: Minor
            Found in firewall/src/http.php - About 35 mins to fix

              Method cuckoo_write has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function cuckoo_write(array &$ctx, string $key, int $ttl_sec, array $item, int $priority = CUCKOO_LOW): bool
              Severity: Minor
              Found in firewall/src/cuckoo.php - About 35 mins to fix

                Method upload_file has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function upload_file(string $url, array $post_data, string $path_to_file, string $file_param, ?string $file_name = null) : ?string {
                Severity: Minor
                Found in firewall/src/api.php - About 35 mins to fix

                  Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function __construct(string $user, string $pass, string $host, string $db_name, string $pre = "") {
                  Severity: Minor
                  Found in firewall/src/db.php - About 35 mins to fix

                    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function __construct(string $filename, string $content, int $write_mode = 0, int $mod_time = 0, bool $append = false) {
                    Severity: Minor
                    Found in firewall/src/util.php - About 35 mins to fix

                      Function executeBound has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
                      Severity: Minor
                      Found in public/underscore.js - About 35 mins to fix

                        Function f has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function f(a,b,c,d,e){b=b||[],c=c||[],d&&(a=d(e,a));var h=/*istanbul ignore start*/void 0;for(h=0;h<b.length;h+=1)if(b[h]===a)return c[h];var i=/*istanbul ignore start*/void 0;if("[object Array]"===k.call(a)){for(b.push(a),i=new Array(a.length),c.push(i),h=0;h<a.length;h+=1)i[h]=f(a[h],b,c,d,e);return b.pop(),c.pop(),i}if(a&&a.toJSON&&(a=a.toJSON()),/*istanbul ignore start*/"object"===("undefined"==typeof/*istanbul ignore end*/a?"undefined":g(a))&&null!==a){b.push(a),i={},c.push(i);var j=[],l=/*istanbul ignore start*/void 0;for(l in a)/* istanbul ignore else */
                        Severity: Minor
                        Found in firewall/views/diff.min.js - About 35 mins to fix

                          Function d has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          "use strict";function c(){}function d(a,b,c,d,e){for(var f=0,g=b.length,h=0,i=0;f<g;f++){var j=b[f];if(j.removed){
                          Severity: Minor
                          Found in firewall/views/diff.min.js - About 35 mins to fix

                            Method onerr has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            function onerr($errno, $errstr, $errfile, $errline, $context = NULL) : bool {
                            Severity: Minor
                            Found in bin/bitfire-install.php - About 35 mins to fix

                              Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  public function __construct(int $code, string $parameter, string $value, string $pattern, int $block_time = 0) {
                              Severity: Minor
                              Found in firewall/src/bitfire.php - About 35 mins to fix

                                Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public function __construct(int $code = 0, string $uuid = 'x', ?string $parameter = NULL, ?string $url = NULL, ?string $host = NULL) {
                                Severity: Minor
                                Found in firewall/src/bitfire.php - About 35 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language