Skip to content

[New Rule] No try block detected when processing system resources #21

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

Closed
lenaorobei opened this issue Jan 29, 2019 · 0 comments
Closed
Labels
accepted New rule is accepted new rule New feature implementation on hold The issue or PR is on hold. technical guidelines The rule is based on Magento Technical Guidelines

Comments

@lenaorobei
Copy link
Contributor

lenaorobei commented Jan 29, 2019

Rule

If a method uses system resources (such as files, sockets, streams, etc), the code MUST be wrapped with a try block and the corresponding finally block. In the finally sections, all resources SHOULD be properly released.

Reason

Source: Magento Technical Guidelines.

Implementation

  • Subscribe to T_STRING token.
  • Prepare the list of build in PHP functions that use resources or alternatively functions prefixes (stream_, socket_, etc)
  • Check if token content is in_array of system functions.
  • Raise a warning if no outer try statement detected.
@lenaorobei lenaorobei added proposal New rule proposal new rule New feature implementation labels Jan 29, 2019
@lenaorobei lenaorobei changed the title [New Rule] No try block detected when processing system resources. [New Rule] No try block detected when processing system resources Jan 29, 2019
@paliarush paliarush added accepted New rule is accepted and removed proposal New rule proposal labels Jan 29, 2019
@lenaorobei lenaorobei added the technical guidelines The rule is based on Magento Technical Guidelines label Jan 30, 2019
@larsroettig larsroettig self-assigned this Mar 8, 2019
@larsroettig larsroettig removed their assignment Mar 16, 2019
@larsroettig larsroettig self-assigned this Mar 29, 2019
larsroettig pushed a commit that referenced this issue Mar 31, 2019
larsroettig pushed a commit that referenced this issue Apr 7, 2019
@lenaorobei lenaorobei added the on hold The issue or PR is on hold. label Apr 24, 2019
larsroettig pushed a commit that referenced this issue Jun 20, 2019
larsroettig pushed a commit that referenced this issue Aug 12, 2019
lenaorobei added a commit that referenced this issue Aug 16, 2019
lenaorobei added a commit that referenced this issue Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted New rule is accepted new rule New feature implementation on hold The issue or PR is on hold. technical guidelines The rule is based on Magento Technical Guidelines
Projects
None yet
Development

No branches or pull requests

3 participants