nutgram/nutgram

View on GitHub

Showing 38 of 59 total issues

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

          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

            Method requestMultipart has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function requestMultipart(
                    string $endpoint,
                    ?array $multipart = null,
                    string $mapTo = stdClass::class,
                    array $options = []
            Severity: Minor
            Found in src/Telegram/Client.php - About 1 hr to fix

              Method handle has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function handle(): int
                  {
                      $bot = app(Nutgram::class);
              
                      $refHandlers = new ReflectionProperty(Nutgram::class, "handlers");
              Severity: Minor
              Found in src/Laravel/Commands/ListCommand.php - About 1 hr to fix

                Method bootstrap has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function bootstrap(string $token, array $config): void
                    {
                        $this->token = $token;
                        $this->config = $config;
                        $this->container = new Container();
                Severity: Minor
                Found in src/Nutgram.php - About 1 hr to fix

                  Method getHandlerName has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function getHandlerName(string $signature): ?string
                      {
                          $signature = Str::lower($signature);
                  
                          return match (Str::before($signature, '.')) {
                  Severity: Minor
                  Found in src/Laravel/Commands/ListCommand.php - About 1 hr to fix

                    Method make has 11 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            int $id,
                            bool $is_bot,
                            string $first_name,
                            ?string $last_name = null,
                            ?string $username = null,
                    Severity: Major
                    Found in src/Telegram/Types/User/User.php - About 1 hr to fix

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

                          protected function addButtonRow(...$buttons): self
                          {
                              foreach ($buttons as $button) {
                                  if ($button->callback_data === null || !str_contains($button->callback_data, '@')) {
                                      continue;
                      Severity: Minor
                      Found in src/Conversations/InlineMenu.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 make has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function make(
                              int $id,
                              string $type,
                              ?string $title = null,
                              ?string $username = null,
                      Severity: Minor
                      Found in src/Telegram/Types/Chat/Chat.php - About 1 hr to fix

                        Method resolveHandlers has 29 lines of code (exceeds 25 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
                          Severity
                          Category
                          Status
                          Source
                          Language