Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore try-catch block as indentation #45

Closed
winkbrace opened this issue Dec 15, 2016 · 3 comments
Closed

ignore try-catch block as indentation #45

winkbrace opened this issue Dec 15, 2016 · 3 comments

Comments

@winkbrace
Copy link

winkbrace commented Dec 15, 2016

Currently any loop or conditional in a try-catch block is reported. The only workaround is to put it in a function, but that doesn't always make sense. It's basically doubling the amount of functions if you need a try-catch block.

try {
    if ($this->eventShouldBeCollected($event)) {
        $this->collectEvent($event);
    }

    $this->fire($event);
} catch (\Exception) {
    // log event errors
}

also in the catch part:

try {
    $this->response = $this->guzzle->request(...);
    // etc..
} catch (\GuzzleHttp\Exception\ClientException $e) {
    if ($e->getResponse()->getStatusCode() == 404) {
        throw VacancyIsClosed::forId($vacancyId);
    }
}
@bmitch
Copy link
Owner

bmitch commented Dec 15, 2016

Thanks @winkbrace. I can take a look at solving this unless you were interested in submitting a pull request?

@winkbrace
Copy link
Author

Okay, good point. I'll give it a try this weekend.

bmitch added a commit that referenced this issue Dec 28, 2016
bmitch added a commit that referenced this issue Dec 28, 2016
@bmitch
Copy link
Owner

bmitch commented Dec 28, 2016

Hey @winkbrace I created a couple of tests for the indentation level sniff using your code snippets above and no errors or warnings were produced. So I was unable to duplicate the issue you are having.

I just committed these tests to the master branch. I'm going to close this for now but if you're still having the same issue can you please let me know? Maybe I'm missing a step in my attempt to duplicate.

@bmitch bmitch closed this as completed Dec 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants