T-Regx/T-Regx

View on GitHub

Showing 13 of 29 total issues

Function consumeGroup has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Confirmed

    private function consumeGroup(EntitySequence $entities): Entity
    {
        $groupDetails = new MatchedString($this->feed, $this->openGroupRegex, 6);
        if (!$groupDetails->matched()) {
            if ($this->imposedNonCapture($entities)) {
Severity: Minor
Found in src/CleanRegex/Internal/Prepared/Parser/Consumer/GroupConsumer.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 withoutUnnamedGroups has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Confirmed

    private function withoutUnnamedGroups(array $groupKeys): array
    {
        $names = [];
        $lastWasString = false;
        foreach ($groupKeys as $groupKey) {
Severity: Minor
Found in src/CleanRegex/Internal/GroupNames.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 consumeGroup has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function consumeGroup(EntitySequence $entities): Entity
    {
        $groupDetails = new MatchedString($this->feed, $this->openGroupRegex, 6);
        if (!$groupDetails->matched()) {
            if ($this->imposedNonCapture($entities)) {
Severity: Minor
Found in src/CleanRegex/Internal/Prepared/Parser/Consumer/GroupConsumer.php - About 1 hr to fix

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

        private function groupOpenRegex(): string
        {
            $namedGroup = "(?:<|P<|') [a-zA-Z0-9_\x80-\xFF@]* [>']?";
            if (Pcre::pcre2()) {
                $flags = '\^?[ismxnUJ]*(?:-[ismxnUJ]*)?';
    Severity: Minor
    Found in src/CleanRegex/Internal/Prepared/Parser/Consumer/GroupConsumer.php - About 1 hr to fix

      Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Confirmed

              Subject            $subject,
              int                $index,
              GroupAware         $groupAware,
              Entry              $matchEntry,
              UsedForGroup       $usedForGroup,
      Severity: Major
      Found in src/CleanRegex/Internal/Match/Details/MatchDetail.php - About 1 hr to fix

        Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Confirmed

            public function __construct(Subject $subject, Signatures $signatures, int $index, MatchAllFactory $allFactory, GroupKeys $groupKeys, Prime $prime)
        Severity: Minor
        Found in src/CleanRegex/Internal/Match/Details/Groups/PrimeDetailGroups.php - About 45 mins to fix

          Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Confirmed

                  GroupAware      $groupAware,
                  UsedForGroup    $usedForGroup,
                  Signatures      $signatures,
                  MatchAllFactory $allFactory,
                  Subject         $subject)
          Severity: Minor
          Found in src/CleanRegex/Internal/Match/Details/DetailGroup.php - About 35 mins to fix

            Method create has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Confirmed

                public static function create(Subject         $subject,
                                              int             $index,
                                              IRawMatchOffset $match,
                                              MatchAllFactory $allFactory,
                                              Prime           $prime): MatchDetail
            Severity: Minor
            Found in src/CleanRegex/Internal/Pcre/DeprecatedMatchDetail.php - About 35 mins to fix

              Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Confirmed

                  public function __construct(string $message, $pattern, string $methodName, int $errorCode, string $errorName)
              Severity: Minor
              Found in src/SafeRegex/Exception/RuntimePregException.php - About 35 mins to fix

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

                    public function __construct(Feed                $feed,
                                                SubpatternFlags     $flags,
                                                GroupAutoCapture    $autoCapture,
                                                PlaceholderConsumer $placeholderConsumer,
                                                Convention          $convention)
                Severity: Minor
                Found in src/CleanRegex/Internal/Prepared/Parser/PcreParser.php - About 35 mins to fix

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

                      public function __construct(Flags $flags, string $keyword, string $pattern, AutoCapture $autoCapture, SubpatternFlags $subpatternFlags)
                  Severity: Minor
                  Found in src/CleanRegex/Internal/Prepared/Template/Mask/KeywordPattern.php - About 35 mins to fix

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

                        private function cleanMessage(string $message): string
                        {
                            if ($message === 'Null byte in regex') {
                                return 'Pattern may not contain null-byte';
                            }
                    Severity: Minor
                    Found in src/SafeRegex/Internal/Factory/CompilePregExceptionFactory.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 matchedGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function matchedGroups(): array
                        {
                            $result = \array_fill(0, $this->groups, null);
                            foreach ($this->matches as $index => [$text, $offset]) {
                                if ($index === 0) {
                    Severity: Minor
                    Found in src/CleanRegex/Internal/Prepared/Parser/Feed/MatchedString.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