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

Empty try-catch block #292

Open
marjanjavid opened this issue Feb 24, 2019 · 7 comments
Open

Empty try-catch block #292

marjanjavid opened this issue Feb 24, 2019 · 7 comments
Assignees
Milestone

Comments

@marjanjavid
Copy link
Collaborator

marjanjavid commented Feb 24, 2019

@Karvan If we have a block like below picture, we should warn about redundant code. Now we just warn about empty finally block.
433

@Karvan Do you agree to add this rule?

@Karvan
Copy link
Collaborator

Karvan commented Feb 25, 2019

@marjanjavid What is redundant here?

@marjanjavid
Copy link
Collaborator Author

@Karvan the empty try-catch is redundant. It doesn't do anything. just redundant lines of codes

@Karvan
Copy link
Collaborator

Karvan commented Feb 25, 2019

@Foroughi Let's do this.

@Karvan Karvan added this to the Release 1.0.7 milestone Feb 25, 2019
@Foroughi
Copy link
Contributor

@marjanjavid @Karvan Isn`t it better instead of we raise a warning for empty try-catch block , we raise a warning for every empty block not just try-catch block ?

@marjanjavid
Copy link
Collaborator Author

marjanjavid commented Mar 6, 2019

@Foroughi I am agree with you. The programmer can put comment in empty blocks to avoid get warning. Please note that we have rules for empty classes, empty methods and empty constructor and empty else clauses in GCop.

@azadimehdi
Copy link

@Karvan Do we need to add any fix providers for this case or only a warning would be enough?

@Karvan
Copy link
Collaborator

Karvan commented Nov 14, 2019

@azadimehdi

  • let's update this rule to check any empty block, not just try-catch.
  • for redundant try-catch we can have another role, as a new feature.

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

4 participants