szepeviktor / phpcs-psr-12-neutron-hybrid-ruleset

My useful frankenstein PHPCS ruleset 👓 for OOP WordPress development
https://packagist.org/packages/szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset
MIT License
10 stars 2 forks source link

Set `ignoreStandaloneIfInScope` in early exit sniff #28

Closed IanDelMar closed 1 month ago

IanDelMar commented 1 month ago

ignoreStandaloneIfInScope ignores an if that is standalone within a scope (see sniff description).

Without setting ignoreStandaloneIfInScope to true, Slevomat enforces changing this:

public function __construct(string $currentWorkingDirectory)
{
    if (self::requireFileExistsExists()) {
        $this->requireFileExistsRule = new PHPStanRequireFileExistsRule($currentWorkingDirectory);
    }
}

to this:

public function __construct(string $currentWorkingDirectory)
{
    if (! self::requireFileExistsExists()) {
        return;
    }
    $this->requireFileExistsRule = new PHPStanRequireFileExistsRule($currentWorkingDirectory);
}

with the following error message: Use early exit to reduce code nesting. Clearly, the nesting is not reduced, and I would argue that a layer of complexity is added.

szepeviktor commented 1 month ago

I am sorry. The happy path should not be in a conditional. https://github.com/szepeviktor/very-clean-code

IanDelMar commented 1 month ago

I agree in most cases, but not for such trivial if conditions where one path results in no action (void). However, I see where you're coming from.

szepeviktor commented 1 month ago

However,

You earn money better than me!!!

IanDelMar commented 1 month ago

Viktor, I don’t think I’ve ever mentioned that all my work with web/WordPress stuff has been entirely voluntary for human rights NGOs – I’ve never earned any money from it. At the moment, I’m not even using the packages I’m contributing to. I understand you’re feeling frustrated, but I’d appreciate it if you could refrain from making assumptions about my income, motivations, or anything else about me that you might not fully know. It’s important to me that we can share different perspectives, even on small matters, while being mindful and respectful of each other.

I genuinely don’t know what it was about the word "however" that was triggering, and I apologise if it came across as condescending or something similar. That was absolutely not my intention.

szepeviktor commented 1 month ago

It is a misunderstanding, Ian. You are a normal developer with real-world attitude. But I am a freaking SCIENTIST with an illness called perfectionism. I cry for days when I see a happy path in a conditional. Sorry about that.

szepeviktor commented 1 month ago

I always try to hide my real self, but sometimes it pops up. Sorry again.

IanDelMar commented 1 month ago

Alright, let's agree that this was a misunderstanding.