Showing 54 of 56 total issues

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

    #[PrimiFunc(callConv: PrimiFunc::CONV_CALLARGS)]
    public static function __op_add__(
        CallArgs $args,
        Context $ctx
    ): AbstractValue {
Severity: Major
Found in src/Stdlib/TypeExtensions/Stdlib/DurationTypeExtension.php and 1 other location - About 3 hrs to fix
src/Stdlib/TypeExtensions/Stdlib/DurationTypeExtension.php on lines 85..105

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

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

    #[PrimiFunc(callConv: PrimiFunc::CONV_CALLARGS)]
    public static function __op_sub__(
        CallArgs $args,
        Context $ctx
    ): AbstractValue {
Severity: Major
Found in src/Stdlib/TypeExtensions/Stdlib/DurationTypeExtension.php and 1 other location - About 3 hrs to fix
src/Stdlib/TypeExtensions/Stdlib/DurationTypeExtension.php on lines 63..83

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

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

AbstractValue has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class AbstractValue extends ValueFriends {

    /** @const string Name of Primi (object) type. */
    public const TYPE = '__undefined__';

Severity: Minor
Found in src/Values/AbstractValue.php - About 3 hrs to fix

    File Repl.php has 287 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    namespace Smuuf\Primi;
    Severity: Minor
    Found in src/Repl.php - About 2 hrs to fix

      Function autocomplete has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
      Open

          private static function autocomplete(
              string $buffer,
              Context $ctx
          ): array {
      
      
      Severity: Minor
      Found in src/Repl.php - About 2 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

      File StringTypeExtension.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace Smuuf\Primi\Stdlib\TypeExtensions;
      Severity: Minor
      Found in src/Stdlib/TypeExtensions/StringTypeExtension.php - About 2 hrs to fix

        Function execute has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
        Open

            public function execute(): void {
        
                $cfg = $this->config;
        
                // Enable verbose logging.
        Severity: Minor
        Found in src/Cli/Entrypoint.php - About 2 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

        Func has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class Func {
        
            /**
             * Pair of regexes to match zeroes at the beginning and at the end of a
             * string, if they're not the last zeroes on that side of decimal point.
        Severity: Minor
        Found in src/Helpers/Func.php - About 2 hrs to fix

          Context has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Context {
          
              use StrictObject;
          
              /** Runtime config bound to this context. */
          Severity: Minor
          Found in src/Context.php - About 2 hrs to fix

            Function mapping_to_couples has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
            Open

                public static function mapping_to_couples(AbstractValue $value) {
            
                    $internalValue = $value->getCoreValue();
                    if ($internalValue instanceof MapContainer) {
            
            
            Severity: Minor
            Found in src/Helpers/Func.php - About 2 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 loop has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
            Open

                private function loop(Context $ctx): void {
            
                    // Print out level (current frame's index in call stack).
                    if (!self::$noExtras) {
                        $level = self::getStackLevel($ctx);
            Severity: Minor
            Found in src/Repl.php - About 2 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 loop has 61 lines of code (exceeds 40 allowed). Consider refactoring.
            Open

                private function loop(Context $ctx): void {
            
                    // Print out level (current frame's index in call stack).
                    if (!self::$noExtras) {
                        $level = self::getStackLevel($ctx);
            Severity: Major
            Found in src/Repl.php - About 1 hr to fix

              Method execute has 60 lines of code (exceeds 40 allowed). Consider refactoring.
              Open

                  public function execute(): void {
              
                      $cfg = $this->config;
              
                      // Enable verbose logging.
              Severity: Major
              Found in src/Cli/Entrypoint.php - About 1 hr to fix

                Function prepareParameters has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
                Open

                    public static function prepareParameters(array $paramsNode): array {
                
                        // Prepare dict array for passing specifics about parameters expected
                        // by the function.
                        // Parameters will be prepared as a dict array with names of parameters
                Severity: Minor
                Found in src/Handlers/Kinds/FunctionDefinition.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 check_allowed_parameter_types_of_function has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
                Open

                    public static function check_allowed_parameter_types_of_function(
                        \ReflectionFunction $rf
                    ): array {
                
                        $types = [];
                Severity: Minor
                Found in src/Helpers/Types.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

                    #[PrimiFunc(callConv: PrimiFunc::CONV_CALLARGS)]
                    public static function __op_eq__(
                        CallArgs $args
                    ): AbstractValue {
                
                
                Severity: Major
                Found in src/Stdlib/TypeExtensions/Stdlib/DurationTypeExtension.php and 1 other location - About 1 hr to fix
                src/Stdlib/TypeExtensions/Stdlib/DatetimeTypeExtension.php on lines 124..140

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

                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

                    #[PrimiFunc]
                    public static function find_last(
                        StringValue $haystack,
                        AbstractValue $needle
                    ): AbstractValue {
                Severity: Major
                Found in src/Stdlib/TypeExtensions/StringTypeExtension.php and 1 other location - About 1 hr to fix
                src/Stdlib/TypeExtensions/StringTypeExtension.php on lines 398..411

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

                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

                    #[PrimiFunc]
                    public static function find_first(StringValue $haystack, AbstractValue $needle): AbstractValue {
                
                        // Allow only some value types.
                        Func::allow_argument_types(1, $needle, StringValue::class, NumberValue::class);
                Severity: Major
                Found in src/Stdlib/TypeExtensions/StringTypeExtension.php and 1 other location - About 1 hr to fix
                src/Stdlib/TypeExtensions/StringTypeExtension.php on lines 423..439

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

                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

                    #[PrimiFunc(callConv: PrimiFunc::CONV_CALLARGS)]
                    public static function __op_eq__(
                        CallArgs $args
                    ): AbstractValue {
                
                
                Severity: Major
                Found in src/Stdlib/TypeExtensions/Stdlib/DatetimeTypeExtension.php and 1 other location - About 1 hr to fix
                src/Stdlib/TypeExtensions/Stdlib/DurationTypeExtension.php on lines 45..61

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

                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 format has 47 lines of code (exceeds 40 allowed). Consider refactoring.
                Open

                    #[PrimiFunc]
                    public static function format(
                        StringValue $str,
                        AbstractValue ...$items
                    ): StringValue {
                Severity: Minor
                Found in src/Stdlib/TypeExtensions/StringTypeExtension.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language