Repository navigation
Conversation
…d via ASSIGN COMPONENT The rule only considered direct assignments of a parameter. A parameter that is written through a field symbol - assigned with ASSIGN COMPONENT ... OF STRUCTURE ... TO FIELD-SYMBOL(<...>) or with ASSIGN ... TO FIELD-SYMBOL(<...>) - was therefore wrongly reported as 'never assigned', as described in issue SAP#612. The variable analysis already records such indirect writes (VariableInfo.mayHaveIndirectWrites(), also used by the 'Make variables FINAL' rule); the rule now takes them into account for EXPORTING, CHANGING and RETURNING parameters. Merely reading through such a field symbol still does not count as an assignment. Adds six test cases to UnusedParametersTest: the scenario from issue SAP#612, an EXPORTING parameter, a component name supplied in a variable, a field symbol declared with FIELD-SYMBOLS, assignment of the whole structure to a field symbol, and a read-only field symbol as a negative case. Signed-off-by: Hafiar <289389248+0xABCD01@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #612.
The "Report unused parameters" rule added a TODO comment such as
" TODO: parameter RS_RESULT is never assigned (ABAP cleaner)for a RETURNING parameter that is assigned indirectly: a component of the parameter is assigned to a field symbol with
ASSIGN COMPONENT ... OF STRUCTURE rs_result TO FIELD-SYMBOL(<...>), and the field symbol is then written to.The variable analysis already records which field symbols point into a variable's memory and whether those field symbols are written to (
VariableInfo.mayHaveIndirectWrites(), also used by the "Make variables FINAL" rule), butUnusedParametersRuleonly looked at direct assignments. It now also takes indirect writes into account for EXPORTING, CHANGING and RETURNING parameters, so no TODO comment is added in this case. Merely reading through such a field symbol still does not count as an assignment, so the TODO comment continues to be added when the parameter is never actually written.Tests: six new test cases in
UnusedParametersTestcover the scenario from issue #612 (RETURNING parameter), an EXPORTING parameter, a component name supplied in a variable, a field symbol declared withFIELD-SYMBOLSinstead of inline, assignment of the whole structure to a field symbol, and a read-only field symbol as a negative case. All 25 tests inUnusedParametersTestpass, and so does the full test suite (3,195 tests).Disclosure: this contribution was prepared with AI assistance, in line with SAP's guideline for AI-generated code contributions. The commit carries a DCO Signed-off-by.