T-Regx/T-Regx

View on GitHub

Showing 17 of 29 total issues

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

<?php
namespace TRegx\SafeRegex\Internal\Constants;

class PregMessages
{
Severity: Major
Found in src/SafeRegex/Internal/Constants/PregMessages.php and 1 other location - About 1 hr to fix
src/SafeRegex/Internal/Constants/PregConstants.php on lines 1..27

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 TRegx\SafeRegex\Internal\Constants;

class PregConstants
{
Severity: Major
Found in src/SafeRegex/Internal/Constants/PregConstants.php and 1 other location - About 1 hr to fix
src/SafeRegex/Internal/Constants/PregMessages.php on lines 1..27

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

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

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

          <?php
          namespace TRegx\CleanRegex\Internal\Prepared\Parser\Entity;
          
          use TRegx\CleanRegex\Internal\AutoCapture\OptionSetting\OptionSetting;
          use TRegx\CleanRegex\Internal\Prepared\Parser\Subpattern;
          src/CleanRegex/Internal/Prepared/Parser/Entity/GroupRemainder.php on lines 1..31

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

          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 TRegx\CleanRegex\Internal\Prepared\Parser\Entity;
          
          use TRegx\CleanRegex\Internal\AutoCapture\OptionSetting\OptionSetting;
          use TRegx\CleanRegex\Internal\Prepared\Parser\Subpattern;
          src/CleanRegex/Internal/Prepared/Parser/Entity/GroupOpenFlags.php on lines 1..31

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

          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 __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