dadajuice/zephyrus

View on GitHub

Showing 84 of 84 total issues

ContentSecurityPolicy has 42 functions (exceeds 20 allowed). Consider refactoring.
Open

class ContentSecurityPolicy
{
    public const SELF = "'self'";
    public const UNSAFE_INLINE = "'unsafe-inline'";
    public const UNSAFE_EVAL = "'unsafe-eval'";
Severity: Minor
Found in src/Zephyrus/Security/ContentSecurityPolicy.php - About 5 hrs to fix

    Function localize has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        public function localize(string $key, array $args = []): string
        {
            $locale = $this->appLocale;
            $segments = explode(".", $key);
            $localizeIdentifier = $segments[0];
    Severity: Minor
    Found in src/Zephyrus/Application/Localization.php - About 4 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

    HttpRequester has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class HttpRequester
    {
        private string $url;
        private string $method;
        private bool $verifySsl = true;
    Severity: Minor
    Found in src/Zephyrus/Network/HttpRequester.php - About 4 hrs to fix

      Function convertFromJSCharCode has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          private function convertFromJSCharCode(string $value): string
          {
              $matches = [];
      
              // check if value matches typical charCode pattern

      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

      FileUpload has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class FileUpload
      {
          /**
           * Original received data array for file upload. Should contain the following keys : ['error', 'tmp_name', 'type',
           * 'name', 'size'].
      Severity: Minor
      Found in src/Zephyrus/Utilities/Uploader/FileUpload.php - About 3 hrs to fix

        Request has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Request
        {
            private ServerEnvironnement $environnement;
            private Url $url;
            private RequestBody $body;
        Severity: Minor
        Found in src/Zephyrus/Network/Request.php - About 3 hrs to fix

          File has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class File extends FileSystemNode
          {
              /**
               * Creates a new file and returns an instance of the newly created file. Will throw an exception if the override
               * argument is set to false and the file already exists.
          Severity: Minor
          Found in src/Zephyrus/Utilities/FileSystem/File.php - About 2 hrs to fix

            CsrfGuard has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class CsrfGuard
            {
                public const HEADER_TOKEN = 'HTTP_X_CSRF_TOKEN';
                public const REQUEST_TOKEN_VALUE = 'CSRFToken';
                public const TOKEN_LENGTH = 48;
            Severity: Minor
            Found in src/Zephyrus/Security/CsrfGuard.php - About 2 hrs to fix

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

                      if (preg_match_all('/(?:(?:[\\\]+\d+[ \t]*){8,})/ims', $value, $matches)) {
                          $converted = '';
                          $charcode = explode('\\', preg_replace('/\s/', '', implode(',', $matches[0])));
              
                          foreach (array_map('octdec', array_filter($charcode)) as $char) {
              src/Zephyrus/Security/IntrusionDetection/Converters/JavascriptConverter.php on lines 65..75

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

              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 (preg_match_all('/(?:(?:[\\\]+\w+\s*){8,})/ims', $value, $matches)) {
                          $converted = '';
                          $charcode = explode('\\', preg_replace('/[ux]/', '', implode(',', $matches[0])));
              
                          foreach (array_map('hexdec', array_filter($charcode)) as $char) {
              src/Zephyrus/Security/IntrusionDetection/Converters/JavascriptConverter.php on lines 52..62

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

              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

              Localization has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Localization
              {
                  private static ?Localization $instance = null;
              
                  /**
              Severity: Minor
              Found in src/Zephyrus/Application/Localization.php - About 2 hrs to fix

                Form has 23 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Form
                {
                    private const SESSION_KEY = '__ZF_FORM_FIELDS';
                
                    /**
                Severity: Minor
                Found in src/Zephyrus/Application/Form.php - About 2 hrs to fix

                  Function getallheaders has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function getallheaders(): array
                      {
                          $headers = [];
                          $copy_server = [
                              'CONTENT_TYPE'   => 'Content-Type',
                  Severity: Minor
                  Found in src/Zephyrus/functions.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

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

                  class WhereCondition
                  {
                      private array $queryParameters;
                      private string $resultSql;
                  
                  
                  Severity: Minor
                  Found in src/Zephyrus/Database/QueryBuilder/WhereCondition.php - About 2 hrs to fix

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

                    class RouteDefinition
                    {
                        private string $rawRouteRoot = "";
                        private string $routeRoot = "";
                        private string $route;
                    Severity: Minor
                    Found in src/Zephyrus/Network/Router/RouteDefinition.php - About 2 hrs to fix

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

                      class Directory extends FileSystemNode
                      {
                          /**
                           * Creates a new directory and returns an instance of the newly created
                           * directory.
                      Severity: Minor
                      Found in src/Zephyrus/Utilities/FileSystem/Directory.php - About 2 hrs to fix

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

                            public static function datetime(DateTime|string|null $dateTime): string
                            {
                                if (is_null($dateTime)) {
                                    return "-";
                                }
                        Severity: Major
                        Found in src/Zephyrus/Utilities/Formatters/TimeFormatter.php and 2 other locations - About 2 hrs to fix
                        src/Zephyrus/Utilities/Formatters/TimeFormatter.php on lines 10..20
                        src/Zephyrus/Utilities/Formatters/TimeFormatter.php on lines 34..44

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

                            public static function date(DateTime|string|null $dateTime): string
                            {
                                if (is_null($dateTime)) {
                                    return "-";
                                }
                        Severity: Major
                        Found in src/Zephyrus/Utilities/Formatters/TimeFormatter.php and 2 other locations - About 2 hrs to fix
                        src/Zephyrus/Utilities/Formatters/TimeFormatter.php on lines 22..32
                        src/Zephyrus/Utilities/Formatters/TimeFormatter.php on lines 34..44

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

                            public static function time(DateTime|string|null $dateTime): string
                            {
                                if (is_null($dateTime)) {
                                    return "-";
                                }
                        Severity: Major
                        Found in src/Zephyrus/Utilities/Formatters/TimeFormatter.php and 2 other locations - About 2 hrs to fix
                        src/Zephyrus/Utilities/Formatters/TimeFormatter.php on lines 10..20
                        src/Zephyrus/Utilities/Formatters/TimeFormatter.php on lines 22..32

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

                            private function prepareMultipartFormData(array $payload): array
                            {
                                $parameters = [];
                                foreach ($payload as $parameterName => $parameterValue) {
                                    // Problem with cURL while sending array in multipart/form-data
                        Severity: Minor
                        Found in src/Zephyrus/Network/HttpRequester/HttpPayload.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