How to work with Code Analysis?

I’m trying to figure out the best way to fix problems reported by Code Analysis.

  • The window “Code Analysis” is a nice report but does not allow to edit the code, so I cannot work with it.
  • Using “Analyze > Find all Violations” shows a list of all violations under “Code Analysis Violations”, but the list is reset whenever I edit my code.
    Highlighting in the editor is refreshed automatically, but the list stays empty. Using “Analyze > Find all Violations” after every change is time-consuming and will always jump back to the first violation
    Is there another way that I am missing? Thanks!

Hi Peter,

You can run CA in the Editor as well. If you’re already in the CA window, do a Ctrl+F9 on your selected object and then click the “Analyze code in current editor window” button, making sure you have the correct ruleset selected in the dropdown. The CA Violations sub-tab will keep your violations persistent so you can select them and they are highlighted in the editor buffer above.

From: Peter Lang [mailto:bounce-PeterLang@toadworld.com]

Sent: Monday, March 07, 2016 3:32 AM

To: toadoraclebeta@toadworld.com

Subject: [Toad for Oracle - Beta Discussion Forum] How to work with Code Analysis?

How to work with Code Analysis?

Thread created by Peter Lang

I’m trying to figure out the best way to fix problems reported by Code Analysis.

  • The window “Code Analysis” is a nice report but does not allow to edit the code, so I cannot work with it.

  • Using “Analyze > Find all Violations” shows a list of all violations under “Code Analysis Violations”, but the list is reset whenever I edit my code.

    Highlighting in the editor is refreshed automatically, but the list stays empty. Using “Analyze > Find all Violations” after every change is time-consuming and will always jump back to the first violation
    Is there another way that I am missing? Thanks!

To reply, please reply-all to this email.

Stop receiving emails on this subject.

Or
Unsubscribe from Toad for Oracle - Beta
notifications altogether.

Toad for Oracle - Beta Discussion Forum

Flag
this post as spam/abuse.

Thanks Brad!

I’m not sure if I follow.

Ctrl+F9 without using F9 before just opens the file in the editor without displaying violations (don’t see “Analyze code in current editor window”).
F9 followed by Ctrl+F9 brings me to the editor and fills the CA Violations sub-tab, but as I said, the list is emptied as soon as I change something in the editor.

but as I said, the list is emptied as soon as I change something in the editor.

Sorry, I missed that part. Indeed, the list is cleared because once you start editing the offsets can change and throw off the results in the sub-tab. The gutter hints are still there and you can always re-run although it would be nice if you could set a keyboard shortcut to do so.

From: Peter Lang [mailto:bounce-PeterLang@toadworld.com]

Sent: Monday, March 07, 2016 9:29 AM

To: toadoraclebeta@toadworld.com

Subject: RE: [Toad for Oracle - Beta Discussion Forum] How to work with Code Analysis?

RE: How to work with Code Analysis?

Reply by Peter Lang

Thanks Brad!

I'm not sure if I follow.

Ctrl+F9 without using F9 before just opens the file in the editor without displaying violations (don't see "Analyze code in current editor window").

F9 followed by Ctrl+F9 brings me to the editor and fills the CA Violations sub-tab, but as I said, the list is emptied as soon as I change something in the editor.

To reply, please reply-all to this email.

Stop receiving emails on this subject.

Or
Unsubscribe from Toad for Oracle - Beta
notifications altogether.

Toad for Oracle - Beta Discussion Forum

Flag
this post as spam/abuse.

A shortcut would help, but I’m not sure if this is ideal.

I certainly don’t have enough background information (e.g. when which rule sets are used), but since the violations are already highlighted in the editor on-the-fly, it would be great to have a list of all highlighted violations that change when editing code. Maybe something like the Eclipse Problems View: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcprbview.htm

Looks like those two features are more separated than I would have expected, though.

Peter,

As far as which rule set is used, you get to pick that (and you can create custom rule sets in Options -> Code Analysis). The main reason we don’t update the list on the fly is simply resources/speed. Basically, if we were to update that list as you type, that’s an extra window that needs to be painted, extra structures that need to be populated, … and we just don’t want to slow down typing. The thought was that the blue “squiggles” and the gutter icons would be enough of an indicator as you’re making your on the fly edits.

Greg

From: Peter Lang [mailto:bounce-PeterLang@toadworld.com]

Sent: Monday, March 07, 2016 10:22 AM

To: toadoraclebeta@toadworld.com

Subject: RE: [Toad for Oracle - Beta Discussion Forum] How to work with Code Analysis?

RE: How to work with Code Analysis?

Reply by Peter Lang

A shortcut would help, but I’m not sure if this is ideal.

I certainly don’t have enough background information (e.g. when which rule sets are used), but since the violations are already highlighted in the editor on-the-fly, it would be great to have a list of all highlighted violations that change when editing code. Maybe something like the Eclipse Problems View:
help.eclipse.org/…/index.jsp

Looks like those two features are more separated than I would have expected, though.

To reply, please reply-all to this email.

Stop receiving emails on this subject.

Or
Unsubscribe from Toad for Oracle - Beta
notifications altogether.

Toad for Oracle - Beta Discussion Forum

Flag
this post as spam/abuse.

Thank you for your answers, I’d really appreciate if you could help me with the following questions:

  • Would it be possible to implement Brad’s suggestion to allow a keyboard shortcut? Right now it’s difficult to fix a package with several errors.
  • “Run Code Analysis for All Items” selects all entries. This can take several minutes after analyzing hundreds of objects and cannot be cancelled.
    Feels like this time is not linear but I’m not sure about that.
  • Can you reproduce that changing the “Default Rule Set” does not affect existing editor tabs?
  • Is there any documentation about creating own rules (like descriptions of the used XPATH objects) or would you assist me with writing own rules?
  • What would be the best way to share my own rules and rule-sets with co-workers?
    Thanks, Peter

This great feature of TOAD has high potential, but I’m struggling with the current implementation.

I have hundreds of objects with many thousand lines of code. I’d like to fix some of the rule violations that TOAD reports in all of my files.

Here is how I try to do this, would really appreciate if you could look into this (and also show me if there are already better ways). Thanks a lot!

Analyzing

  • Open “Code Analysis”

  • Define my own Rule Set with the relevant rules

  • “Load all objects”:

    • Problem: This takes over a minute. Looks like views are the bottleneck.
  • “Run Code Analysis for all items”

    • Problem: After all objects have been analyzed, it takes a lot more time since TOAD selects all the objects
  • Order by number of rule violations to find those objects that have problems

  • Open objects with problems in editor

  • Ideas to discuss

    • Have a look why loading views takes so long
    • Do not select all objects after analyzing
      Fixing violations
  • Right-Click -> Analyze -> Find All Violations

    • Problem: Difficult to locate in large right-click-menu, but did not find a way to define a shortcut
    • Problem: Once no violations exist any more, instead of displaying empty “Code Analysis Violations” the tab just does not appear and TOAD jumps to the first entry in “CRUD Locations” since I called “Analyze Code” in the editor earlier. This is confusing.
  • Realize that my custom rule is not selected as Default Rule Set, go to options and change

    • Problem: This does not seem to affect files that have already been opened in the editor
  • Fix the first violation

    • Problem: List of violations is gone, need to analyze again (shortcut would help)
    • Problem: Unable to skip current problem and navigate to next without using mouse (shortcut for “Find All Violations” would also not really help any more, since it would jump to the first violation again)
  • Give up using “Find All Violations” and scroll through the file trying to spot the blue exclamation marks

    • Problem: Inefficient
  • Ideas to discuss

    • Apply changes of the “Default Rule Set” to the current editor
    • Display “Code Analysis Violations” without entries when everything is ok
    • Since the editor already highlights the violations automatically, would it be possible to define two actions (with shortcuts) to jump to the previous/next rule violation starting from my current cursor position? This would allow me to skip “Find All Violations” at all, I could just navigate through my violations and decide which ones to fix. Waiting for a second until the asynchronous violation-highlighting is updated automatically (or risking to jump to a wrong location since I changed some code at the current position) sounds like a problem I could accept.
      Re-Analyzing (make sure that all problems have been fixed)
  • Go back to “Code Analyzis” (still open)

  • Select objects that had problems before and try to analyze all selected objects (only those that had problems before)

    • Problem: Since code is not reloaded, the results do not change
  • Since the list is quite long, I cannot open the objects that had problems again, so I have clear the list and call “Load all objects” again

    • Problem: Even if speed of loading/analyzing could be greatly improved, this is still an unnecessary step
  • Ideas to discuss

    • Tell me what I’m doing wrong :wink:
    • Allow to reload selected objects?