palicao/phpRedisTimeSeries

View on GitHub

Showing 16 of 16 total issues

File TimeSeries.php has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare(strict_types=1);

namespace Palicao\PhpRedisTimeSeries;

Severity: Minor
Found in src/TimeSeries.php - About 4 hrs to fix

    TimeSeries has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class TimeSeries
    {
        public const DUPLICATE_POLICY_BLOCK = 'BLOCK';
        public const DUPLICATE_POLICY_FIRST = 'FIRST';
        public const DUPLICATE_POLICY_LAST = 'LAST';
    Severity: Minor
    Found in src/TimeSeries.php - About 2 hrs to fix

      Method connectIfNeeded has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function connectIfNeeded(): void
          {
              if ($this->redis->isConnected()) {
                  return;
              }
      Severity: Minor
      Found in src/Client/RedisClient.php - About 1 hr to fix

        Method toRedisParams has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function toRedisParams(): array
            {
                $params = [];
                foreach ($this->filters as $filter) {
                    switch ($filter[1]) {
        Severity: Minor
        Found in src/Filter.php - About 1 hr to fix

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

                  DateTimeInterface $lastTimestamp,
                  int $retentionTime = 0,
                  int $chunkCount = 0,
                  int $maxSamplesPerChunk = 0,
                  array $labels = [],
          Severity: Major
          Found in src/Metadata.php - About 50 mins to fix

            Method multiRangeRaw has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    Filter $filter,
                    ?DateTimeInterface $from = null,
                    ?DateTimeInterface $to = null,
                    ?int $count = null,
                    ?AggregationRule $rule = null,
            Severity: Major
            Found in src/TimeSeries.php - About 50 mins to fix

              Method fromRedis has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      int $lastTimestamp,
                      int $retentionTime = 0,
                      int $chunkCount = 0,
                      int $maxSamplesPerChunk = 0,
                      array $labels = [],
              Severity: Major
              Found in src/Metadata.php - About 50 mins to fix

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

                        string $key,
                        ?int $retentionMs = null,
                        array $labels = [],
                        bool $uncompressed = false,
                        ?int $chunkSize = null,
                Severity: Minor
                Found in src/TimeSeries.php - About 45 mins to fix

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

                          Sample $sample,
                          ?int $retentionMs = null,
                          array $labels = [],
                          bool $uncompressed = false,
                          ?int $chunkSize = null,
                  Severity: Minor
                  Found in src/TimeSeries.php - About 45 mins to fix

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

                            Filter $filter,
                            ?DateTimeInterface $from = null,
                            ?DateTimeInterface $to = null,
                            ?int $count = null,
                            ?AggregationRule $rule = null,
                    Severity: Minor
                    Found in src/TimeSeries.php - About 45 mins to fix

                      Function toRedisParams has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function toRedisParams(): array
                          {
                              $params = [];
                              foreach ($this->filters as $filter) {
                                  switch ($filter[1]) {
                      Severity: Minor
                      Found in src/Filter.php - About 45 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 multiRange has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              Filter $filter,
                              ?DateTimeInterface $from = null,
                              ?DateTimeInterface $to = null,
                              ?int $count = null,
                              ?AggregationRule $rule = null,
                      Severity: Minor
                      Found in src/TimeSeries.php - About 45 mins to fix

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

                                string $key,
                                ?DateTimeInterface $from = null,
                                ?DateTimeInterface $to = null,
                                ?int $count = null,
                                ?AggregationRule $rule = null,
                        Severity: Minor
                        Found in src/TimeSeries.php - About 45 mins to fix

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

                                  string $op,
                                  Sample $sample,
                                  ?int $resetMs = null,
                                  ?int $retentionMs = null,
                                  array $labels = []
                          Severity: Minor
                          Found in src/TimeSeries.php - About 35 mins to fix

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

                                private function authenticate(?string $username, ?string $password): void
                                {
                                    try {
                                        if ($password) {
                                            if ($username) {
                            Severity: Minor
                            Found in src/Client/RedisClient.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

                            Function add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function add(string $label, int $operation, $value = null): self
                                {
                                    if (!in_array($operation, self::OPERATIONS, true)) {
                                        throw new InvalidFilterOperationException('Operation is not valid');
                                    }
                            Severity: Minor
                            Found in src/Filter.php - About 25 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

                            Severity
                            Category
                            Status
                            Source
                            Language