mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Add "Correct Usage" and "Incorrect Usage" headings
This commit is contained in:
@@ -11,6 +11,8 @@ Note: You do not need to explicitly initialize the variable, if you can make the
|
||||
|
||||
## Example
|
||||
|
||||
### Incorrect Usage
|
||||
|
||||
In the following code, the call to `create_file` may fail and then the call `f.close` will raise a `NoMethodError` since `f` will be `nil` at that point.
|
||||
|
||||
```ruby
|
||||
@@ -22,6 +24,8 @@ ensure
|
||||
end
|
||||
```
|
||||
|
||||
### Correct Usage
|
||||
|
||||
We can fix this by using safe navigation:
|
||||
```ruby
|
||||
def dump(x)
|
||||
|
||||
Reference in New Issue
Block a user