nutgram/nutgram

View on GitHub

Showing 33 of 33 total issues

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 resolveNestedGroups has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function resolveNestedGroups(
        array $groups,
        array $currentMiddlewares = [],
        array $currentScopes = [],
        array $currentTags = [],
Severity: Minor
Found in src/Handlers/ResolveHandlers.php - About 1 hr to fix

    Method parseHeaders has 27 lines of code (exceeds 25 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

      Function closeMenu has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function closeMenu(?string $finalText = null, array $opt = [], bool $reopen = false): bool|Message
          {
              if ($reopen) {
                  $this->chatId = $this->messageId = null;
              }
      Severity: Minor
      Found in src/Conversations/InlineMenu.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

      Method wallpaperFreeformGradientPattern has 7 arguments (exceeds 5 allowed). Consider refactoring.
      Open

              string $slug,
              int $intensity,
              string $hexColor1,
              string $hexColor2,
              string $hexColor3,
      Severity: Major
      Found in src/Support/DeepLink.php - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

                    if (
                        ($subType !== null && $handler->getPattern() === $subType) ||
                        ($value === null && $handler->getPattern() === null) ||
                        ($value !== null && $handler->matching($value))
                    ) {
        Severity: Major
        Found in src/Handlers/ResolveHandlers.php - About 40 mins to fix

          Method publicMessage has 6 arguments (exceeds 5 allowed). Consider refactoring.
          Open

                  string $username,
                  int $messageId,
                  ?int $threadId = null,
                  bool $single = false,
                  ?int $comment = null,
          Severity: Minor
          Found in src/Support/DeepLink.php - About 35 mins to fix

            Method wallpaperGradientPattern has 6 arguments (exceeds 5 allowed). Consider refactoring.
            Open

                    string $slug,
                    int $intensity,
                    string $topColor,
                    string $bottomColor,
                    int $rotation = 0,
            Severity: Minor
            Found in src/Support/DeepLink.php - About 35 mins to fix

              Method privateMessage has 6 arguments (exceeds 5 allowed). Consider refactoring.
              Open

                      int $chatId,
                      int $messageId,
                      ?int $threadId = null,
                      bool $single = false,
                      ?int $comment = null,
              Severity: Minor
              Found in src/Support/DeepLink.php - About 35 mins to fix

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

                    public function processUpdates(Nutgram $bot): void
                    {
                        $config = $bot->getConfig();
                        $offset = 1;
                
                
                Severity: Minor
                Found in src/RunningMode/Polling.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 hearUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function hearUpdate(Update $update): self
                    {
                        if ($this->commonUser !== null) {
                            $update->setUser($this->commonUser);
                        }
                Severity: Minor
                Found in src/Testing/Hears.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

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

                    protected function applyGlobalMiddlewareTo(Handler $handler): void
                    {
                        $skippedGlobalMiddlewares = $handler->getSkippedGlobalMiddlewares();
                
                        if ($handler->isSkippingGlobalMiddlewares() && empty($skippedGlobalMiddlewares)) {
                Severity: Minor
                Found in src/Handlers/ResolveHandlers.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

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

                    private function getReflectionClass(string $class, array $context = []): ReflectionClass
                    {
                        $reflectionClass = new ReflectionClass($class);
                
                        if ($reflectionClass->isAbstract()) {
                Severity: Minor
                Found in src/Testing/TypeFaker.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