nutgram/nutgram

View on GitHub

Showing 50 of 59 total issues

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

<?php

namespace SergiX44\Nutgram\Telegram\Types\Inline;

use SergiX44\Hydrator\Annotation\Alias;
Severity: Major
Found in src/Telegram/Types/Inline/InlineQueryResultMpeg4Gif.php and 1 other location - About 5 hrs to fix
src/Telegram/Types/Inline/InlineQueryResultGif.php on lines 1..116

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

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

<?php

namespace SergiX44\Nutgram\Telegram\Types\Inline;

use SergiX44\Hydrator\Annotation\Alias;
Severity: Major
Found in src/Telegram/Types/Inline/InlineQueryResultGif.php and 1 other location - About 5 hrs to fix
src/Telegram/Types/Inline/InlineQueryResultMpeg4Gif.php on lines 1..116

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

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 make has 28 arguments (exceeds 4 allowed). Consider refactoring.
Open

        int $id,
        string $type,
        ?string $title = null,
        ?string $username = null,
        ?string $first_name = null,
Severity: Major
Found in src/Telegram/Types/Chat/Chat.php - About 3 hrs to fix

    Function fakeInstance has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        private function fakeInstance(
            string $class,
            array $additional = [],
            bool $fillNullable = true,
            array $resolveStack = []
    Severity: Minor
    Found in src/Testing/TypeFaker.php - About 3 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

    Function wordWrap has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function wordWrap(string $string, int $width = 75, string $break = "\n", bool $cut = false): string
        {
            if ($string === '') {
                return '';
            }
    Severity: Minor
    Found in src/Support/StrUtils.php - About 3 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

    Method fakeInstance has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function fakeInstance(
            string $class,
            array $additional = [],
            bool $fillNullable = true,
            array $resolveStack = []
    Severity: Major
    Found in src/Testing/TypeFaker.php - About 2 hrs to fix

      Method inject has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function inject(Nutgram $bot, MockHandler $mock, HandlerStack $handlerStack): void
          {
              (function () use ($handlerStack, $mock) {
                  /** @psalm-scope-this SergiX44\Nutgram\Testing\FakeNutgram */
                  $this->mockHandler = $mock;
      Severity: Minor
      Found in src/Testing/FakeNutgram.php - About 1 hr to fix

        Function parseHeaders has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function parseHeaders(string $headerContent): array
            {
                $headers = [];
                $headerParts = preg_split('/\\R/s', $headerContent, -1, PREG_SPLIT_NO_EMPTY);
                foreach ($headerParts as $headerPart) {
        Severity: Minor
        Found in src/Testing/FormDataParser.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 addHandlersBy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function addHandlersBy(
                array &$handlers,
                string $type,
                ?string $subType = null,
                ?string $value = null
        Severity: Minor
        Found in src/Handlers/ResolveHandlers.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 continueConversation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function continueConversation(Conversation|callable $conversation): array
            {
                $resolvedHandlers = [];
        
                if (!$conversation instanceof Conversation || !$conversation->skipHandlers()) {
        Severity: Minor
        Found in src/Handlers/ResolveHandlers.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

        Method wordWrap has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function wordWrap(string $string, int $width = 75, string $break = "\n", bool $cut = false): string
            {
                if ($string === '') {
                    return '';
                }
        Severity: Minor
        Found in src/Support/StrUtils.php - About 1 hr to fix

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

              public function assertActiveConversation(?int $userId = null, ?int $chatId = null): self
              {
                  $userId = $this->storedUser?->id ?? $userId;
                  $chatId = $this->storedChat?->id ?? $chatId;
          
          
          Severity: Major
          Found in src/Testing/Asserts.php and 1 other location - About 1 hr to fix
          src/Testing/Asserts.php on lines 133..145

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

          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

              public function assertNoConversation(?int $userId = null, ?int $chatId = null): self
              {
                  $userId = $this->storedUser?->id ?? $userId;
                  $chatId = $this->storedChat?->id ?? $chatId;
          
          
          Severity: Major
          Found in src/Testing/Asserts.php and 1 other location - About 1 hr to fix
          src/Testing/Asserts.php on lines 114..126

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

          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

          <?php
          
          namespace SergiX44\Nutgram\Telegram\Types\Inline;
          
          use SergiX44\Hydrator\Annotation\ArrayType;
          src/Telegram/Types/Inline/InlineQueryResultCachedVideo.php on lines 1..78

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

          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

          <?php
          
          namespace SergiX44\Nutgram\Telegram\Types\Inline;
          
          use SergiX44\Hydrator\Annotation\ArrayType;
          Severity: Major
          Found in src/Telegram/Types/Inline/InlineQueryResultCachedVideo.php and 1 other location - About 1 hr to fix
          src/Telegram/Types/Inline/InlineQueryResultCachedDocument.php on lines 1..80

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

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

              protected function parseRequest(): self
              {
                  //get method type
                  $this->method = $this->request->getMethod();
          
          
          Severity: Minor
          Found in src/Testing/FormDataParser.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

          Method parseRequest has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function parseRequest(): self
              {
                  //get method type
                  $this->method = $this->request->getMethod();
          
          
          Severity: Minor
          Found in src/Testing/FormDataParser.php - About 1 hr to fix

            Function resolveHandlers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function resolveHandlers(): array
                {
                    $resolvedHandlers = [];
                    $updateType = $this->update->getType();
            
            
            Severity: Minor
            Found in src/Handlers/ResolveHandlers.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

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

            <?php
            
            namespace SergiX44\Nutgram\Telegram\Types\Inline;
            
            use SergiX44\Hydrator\Annotation\ArrayType;
            Severity: Major
            Found in src/Telegram/Types/Inline/InlineQueryResultCachedGif.php and 1 other location - About 1 hr to fix
            src/Telegram/Types/Inline/InlineQueryResultCachedMpeg4Gif.php on lines 1..74

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

            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

            <?php
            
            namespace SergiX44\Nutgram\Telegram\Types\Inline;
            
            use SergiX44\Hydrator\Annotation\ArrayType;
            src/Telegram/Types/Inline/InlineQueryResultCachedGif.php on lines 1..73

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

            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

            Severity
            Category
            Status
            Source
            Language