Skip to content

Commit

Permalink
[self-in-block] Improve autofix for strongSelfNotChecked
Browse files Browse the repository at this point in the history
Summary: The line number for the autofix was off by one. We need the check in the line after the definition of `strongSelf`.

Reviewed By: skcho

Differential Revision: D64971741

fbshipit-source-id: a05e16f9968c4f0c331c0accfa09694c7cd01509
  • Loading branch information
dulmarod authored and facebook-github-bot committed Oct 25, 2024
1 parent 92e7116 commit 774f9d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion infer/src/checkers/SelfInBlock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ module Mem = struct
{ Jsonbug_t.original= None
; replacement= None
; additional=
Some [{Jsonbug_t.line= strong_self_line; column= 1; original= ""; replacement}]
Some
[{Jsonbug_t.line= strong_self_line + 1; column= 1; original= ""; replacement}]
}
| _ ->
None
Expand Down
2 changes: 1 addition & 1 deletion infer/tests/codetoanalyze/objc/self-in-block/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ codetoanalyze/objc/self-in-block/SelfInBlockPassedToInit.m, objc_block_SelfInBlo
codetoanalyze/objc/self-in-block/SelfInBlockPassedToInit.m, objc_block_SelfInBlockPassedToInit.m:17, 2, SELF_IN_BLOCK_PASSED_TO_INIT, no_bucket, ERROR, [Using captured &self,Using captured &self]
codetoanalyze/objc/self-in-block/StrongSelf.m, objc_block_StrongSelf.m:65, 4, MIXED_SELF_WEAKSELF, no_bucket, ERROR, [Using &weakSelf,Using &self,Using &self], "self"=>"strongSelf"@69:15
codetoanalyze/objc/self-in-block/StrongSelf.m, objc_block_StrongSelf.m:78, 1, CAPTURED_STRONG_SELF, no_bucket, ERROR, [Using captured &weakSelf]
codetoanalyze/objc/self-in-block/StrongSelf.m, objc_block_StrongSelf.m:106, 6, STRONG_SELF_NOT_CHECKED, no_bucket, ERROR, [&strongSelf assigned here,Using &strongSelf not checked for null,Using &strongSelf not checked for null], +""=>"\n if (!strongSelf) { return; }"@107:1
codetoanalyze/objc/self-in-block/StrongSelf.m, objc_block_StrongSelf.m:106, 6, STRONG_SELF_NOT_CHECKED, no_bucket, ERROR, [&strongSelf assigned here,Using &strongSelf not checked for null,Using &strongSelf not checked for null], +""=>"\n if (!strongSelf) { return; }"@108:1
codetoanalyze/objc/self-in-block/StrongSelf.m, objc_block_StrongSelf.m:121, 6, STRONG_SELF_NOT_CHECKED, no_bucket, ERROR, [&strongSelf assigned here,Using &strongSelf not checked for null,Using &strongSelf not checked for null]
codetoanalyze/objc/self-in-block/StrongSelf.m, objc_block_StrongSelf.m:158, 2, STRONG_SELF_NOT_CHECKED, no_bucket, ERROR, [&strongSelf assigned here,Using &strongSelf not checked for null]
codetoanalyze/objc/self-in-block/StrongSelf.m, objc_block_StrongSelf.m:170, 2, STRONG_SELF_NOT_CHECKED, no_bucket, ERROR, [&strongSelf assigned here,Using &strongSelf not checked for null,Using &strongSelf not checked for null]
Expand Down

0 comments on commit 774f9d9

Please sign in to comment.