efureev/php-support

View on GitHub

Showing 43 of 43 total issues

Function groupBy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function groupBy(callable|array|string $groupBy, bool $preserveKeys = false): static
    {
        if (is_array($groupBy) && !$this->useAsCallable($groupBy)) {
            $nextGroups = $groupBy;

Severity: Minor
Found in src/Structures/Collections/ArrayCollection.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 downcode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function downcode(string $text, string $language = ''): string
    {
        self::initLanguageMap($language);

        if (self::seemsUTF8($text)) {
Severity: Minor
Found in src/Helpers/URLify.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 function has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  function: (params, onError) => {
    params.tokens.filter(function filterToken(token) {
      return token.type === "heading_open";
    }).forEach(function forToken(token) {
      if (token.tag === "h2") {
Severity: Minor
Found in .github/workflows/lint/rules/changelog.js - 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

Method assertClassUsesTraits has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function assertClassUsesTraits($class, $expected_traits, string $message = ''): void
    {
        /**
         * Returns all traits used by a trait and its traits.
         *
Severity: Minor
Found in src/Testing/AdditionalAssertionsTrait.php - About 1 hr to fix

    Method dataGet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function dataGet(mixed $target, string|array|int|null $key, mixed $default = null): mixed
        {
            if ($key === null) {
                return $target;
            }
    Severity: Minor
    Found in src/Global/base.php - About 1 hr to fix

      Method dataToArray has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function dataToArray(mixed $items): mixed
          {
              if (is_object($items)) {
                  if ($items instanceof JsonSerializable) {
                      return static::dataToArray($items->jsonSerialize());
      Severity: Minor
      Found in src/Helpers/Arr.php - About 1 hr to fix

        Method sortByMany has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function sortByMany(array $comparisons = []): static
            {
                $items = $this->elements;
        
                uasort(
        Severity: Minor
        Found in src/Structures/Collections/ArrayCollection.php - About 1 hr to fix

          Method groupBy has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function groupBy(callable|array|string $groupBy, bool $preserveKeys = false): static
              {
                  if (is_array($groupBy) && !$this->useAsCallable($groupBy)) {
                      $nextGroups = $groupBy;
          
          
          Severity: Minor
          Found in src/Structures/Collections/ArrayCollection.php - About 1 hr to fix

            Function get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function get(mixed $array, string|int|null $key, mixed $default = null, string $separator = '.'): mixed
                {
                    if (!static::accessible($array)) {
                        return value($default);
                    }
            Severity: Minor
            Found in src/Helpers/Arr.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 random has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function random(array $array, ?int $number = null, bool $preserveKeys = false): mixed
                {
                    $requested = $number ?? 1;
            
                    $count = count($array);
            Severity: Minor
            Found in src/Helpers/Arr.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

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

                    'lt'            => [/* Lithuanian */
                        'ą' => 'a',
                        'č' => 'c',
                        'ę' => 'e',
                        'ė' => 'e',
            Severity: Major
            Found in src/Helpers/URLify.php and 2 other locations - About 45 mins to fix
            src/Helpers/URLify.php on lines 303..322
            src/Helpers/URLify.php on lines 323..342

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

            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

                    'cs'            => [/* Czech */
                        'č' => 'c',
                        'ď' => 'd',
                        'ě' => 'e',
                        'ň' => 'n',
            Severity: Major
            Found in src/Helpers/URLify.php and 2 other locations - About 45 mins to fix
            src/Helpers/URLify.php on lines 323..342
            src/Helpers/URLify.php on lines 376..395

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

            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

                    'pl'            => [/* Polish */
                        'ą' => 'a',
                        'ć' => 'c',
                        'ę' => 'e',
                        'ł' => 'l',
            Severity: Major
            Found in src/Helpers/URLify.php and 2 other locations - About 45 mins to fix
            src/Helpers/URLify.php on lines 303..322
            src/Helpers/URLify.php on lines 376..395

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

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

                private static function initLanguageMap(string $language = ''): void
                {
                    if (count(self::$map) > 0 && (($language === '') || ($language === self::$language))) {
                        return;
                    }
            Severity: Minor
            Found in src/Helpers/URLify.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

            Avoid too many return statements within this method.
            Open

                            return value($default);
            Severity: Major
            Found in src/Helpers/Arr.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $array;
              Severity: Major
              Found in src/Helpers/Arr.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return (array)$items;
                Severity: Major
                Found in src/Helpers/Arr.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return (array)$items->jsonSerialize();
                  Severity: Major
                  Found in src/Helpers/Arr.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return value($default);
                    Severity: Major
                    Found in src/Global/base.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $target;
                      Severity: Major
                      Found in src/Global/base.php - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language