# Code Analysis: Rule 5406 (unused parameters) not triggered as expected

**URL:** <https://forums.toadworld.com/t/code-analysis-rule-5406-unused-parameters-not-triggered-as-expected/38446>\
**Category:** Toad for Oracle - Beta\
**Created:** [October 3, 2016, 7:00am UTC](https://forums.toadworld.com/t/code-analysis-rule-5406-unused-parameters-not-triggered-as-expected/38446 "2016-10-03T07:00:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterLang](https://avatars.discourse-cdn.com/v4/letter/p/71e660/32.png) [@PeterLang](https://forums.toadworld.com/u/PeterLang)\
**Post date:** [October 3, 2016, 7:00am UTC](https://forums.toadworld.com/t/code-analysis-rule-5406-unused-parameters-not-triggered-as-expected/38446/1 "2016-10-03T07:00:35Z")

</div>

In the following example param\_1 is unused in both procedures, but only detected in the first one since the parameter name is used as named parameter when calling the first procedure. Version: 12.10.0.25.

DECLARE  
PROCEDURE my\_procedure\_1( param\_1 IN NUMBER ) AS – detected as expected  
BEGIN  
NULL;  
END;

PROCEDURE my\_procedure\_2( param\_1 IN NUMBER ) AS – not detected  
BEGIN  
my\_procedure\_1( **param\_1** =\> NULL );  
END;  
BEGIN  
NULL;  
END;

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [October 3, 2016, 11:02am UTC](https://forums.toadworld.com/t/code-analysis-rule-5406-unused-parameters-not-triggered-as-expected/38446/2 "2016-10-03T11:02:28Z")

</div>

Hi Peter,

I understand that you expected my\_procedure\_2 to “see” that param\_1 passed to my\_procedure\_1 is eventually unused.

Currently, unused parameters are only detected in the scope of the current code unit. So, related to my\_procedure\_2, parameter param\_1 is “used” as it is passed to some procedure. This may sure make sense as my\_procedure\_1 could be a temporary stub, to be completed later. Unused could become used soon.

Having said that, there is always room for a rule which could detected “eventually unused” conditions. But we don’t have that today.

Thanks,  
Andre

---

<div class="post-metadata">

**Author:** ![PeterLang](https://avatars.discourse-cdn.com/v4/letter/p/71e660/32.png) [@PeterLang](https://forums.toadworld.com/u/PeterLang)\
**Post date:** [October 3, 2016, 11:03pm UTC](https://forums.toadworld.com/t/code-analysis-rule-5406-unused-parameters-not-triggered-as-expected/38446/3 "2016-10-03T23:03:44Z")

</div>

Hi Andre,

no, I think you got me wrong, let me try to explain it again. The fact that my\_procedure\_1 does not use the parameter is a problem of my\_procedure\_1 only, in my opinion there is no need for my\_procedure\_2 to know.

The problem is that my\_procedure\_2 does not use its own parameter.  
This call of my\_procedure\_1 passes NULL, param\_1 is not the parameter passed to my\_procedure\_2 but the name of the parameter of my\_procedure\_1.

If the name of the parameter of my\_procedure\_1 would be different, it would be detected just fine:

DECLARE  
PROCEDURE my\_procedure\_1( **param\_2** IN NUMBER ) AS – detected as expected  
BEGIN  
NULL;  
END;

PROCEDURE my\_procedure\_2( param\_1 IN NUMBER ) AS – detected as expected  
BEGIN  
my\_procedure\_1( **param\_2** =\> NULL );  
END;  
BEGIN  
NULL;  
END;

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [October 3, 2016, 11:50pm UTC](https://forums.toadworld.com/t/code-analysis-rule-5406-unused-parameters-not-triggered-as-expected/38446/4 "2016-10-03T23:50:37Z")

</div>

My gosh, you’re right of course! The parameter param\_1 of …proc\_2 is unused indeed.

Thanks for this case, is on the fix list. (QP-1859)  
Andre

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [November 17, 2016, 8:40am UTC](https://forums.toadworld.com/t/code-analysis-rule-5406-unused-parameters-not-triggered-as-expected/38446/5 "2016-11-17T08:40:09Z")

</div>

This has been addressed, soon to show up in a new Toad having QP5 version 5.305 (or later).  
In addition, the following issues were detected and fixed:

- Nested variable declarations and parameter declarations in nested program units or cursors are taken into account.,
- Items in select lists are no longer discarded,
- In qualified names now only the leftmost identifier is taken into account.  
Thanks,  
Andre
