| <!doctype html> |
| <html class="no-js" lang="en" dir="ltr"> |
| <head> |
| <meta charset="utf-8"> |
| <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| <title>Static Code Analysis in the NetBeans IDE Java Editor</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <meta name="description" content="Static Code Analysis in the NetBeans IDE Java Editor - Apache NetBeans"> |
| <meta name="author" content="Apache NetBeans"> |
| <meta name="description" content="Static Code Analysis in the NetBeans IDE Java Editor - Apache NetBeans"> |
| <meta name="keywords" content="Apache NetBeans, Tutorials, Static Code Analysis in the NetBeans IDE Java Editor"> |
| <meta name="generator" content="Apache NetBeans"> |
| <link rel="stylesheet" href="../../../../../../_/css/font-awesome.min.css"> |
| <link rel="alternate" type="application/atom+xml" title="Apache NetBeans Blog" href="https://netbeans.apache.org/blogs/atom" /> |
| <link rel="stylesheet" href="../../../../../../_/css/highlightjs/default.min.css"> |
| <link rel="stylesheet" href="../../../../../../_/css/netbeans.css"> |
| <link rel="apple-touch-icon" sizes="180x180" href="../../../../../../_/images/fav/apple-touch-icon.png"> |
| <link rel="icon" type="image/png" sizes="32x32" href="../../../../../../_/images/fav/favicon-32x32.png"> |
| <link rel="icon" type="image/png" sizes="16x16" href="../../../../../../_/images/fav/favicon-16x16.png"> |
| <link rel="manifest" href="../../../../../../_/images/fav/site.webmanifest"> |
| <link rel="mask-icon" href="../../../../../../_/images/fav/safari-pinned-tab.svg" color="#5bbad5"> |
| <meta name="msapplication-TileColor" content="#ffc40d"> |
| <meta name="theme-color" content="#ffffff"> |
| <link href="../../../../../../_/css/font-open-sans.css" rel="stylesheet"> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| http://www.apache.org/licenses/LICENSE-2.0 |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| </head> |
| <body> |
| <div class="title-bar" data-responsive-toggle="responsive-menu" data-hide-for="medium"> |
| <button type="button" data-toggle="responsive-menu"><i style='font-size: 32px; color: #fff; padding: 8px' class='fa fa-bars'></i></button> |
| <div class="title-bar-title">Apache NetBeans</div> |
| </div> |
| <div class="top-bar" id="responsive-menu"> |
| <div class='top-bar-left'> |
| <a class='title' href="../../../../../../index.html"><img src='../../../../../../_/images/apache-netbeans.svg' style='padding: 8px; height: 48px;'> Apache NetBeans</a> |
| </div> |
| <div class="top-bar-right"> |
| <ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown"> |
| <li> <input id="search-input" type="text" placeholder="Search the docs"> </li> |
| <li> <a href="../../../../../../front/main/community">Community</a> </li> |
| <li> <a href="../../../../../../front/main/participate">Participate</a> </li> |
| <li> <a href="../../../../../../front/main/blogs">Blog</a></li> |
| <li> <a href="../../../../../../front/main/help">Get Help</a> </li> |
| <li> <a href="https://plugins.netbeans.apache.org/">Plugins</a> </li> |
| <li> <a href="../../../../../../front/main/download">Download</a> </li> |
| </ul> |
| </div> |
| </div> |
| |
| <!-- src/templates/news --> |
| <section class="hero news alternate"> |
| <div class='grid-container'> |
| <div class='cell'> |
| <div class="annotation">Latest release</div> |
| <h1>Apache NetBeans 27</h1> |
| <p><a class="button success" href="../../../../../../front/main/download/nb27">Download</a></p> |
| </div> |
| </div> |
| </section> |
| <div class='grid-container main-content tutorial'> |
| <article class="doc"> |
| <h1 class="sect0">Static Code Analysis in the NetBeans IDE Java Editor</h1> |
| <div class="sectionbody"> |
| <div class="admonitionblock note"> |
| <table> |
| <tbody><tr> |
| <td class="icon"><i class="fa icon-note" title="Note"></i></td> |
| <td class="content">This tutorial needs a review. |
| You can <a href="https://github.com/apache/netbeans-antora-tutorials/edit/main/modules/ROOT/pages/kb/docs/java/code-inspect.adoc" title="Edit this tutorial in github">edit it in GitHub </a> |
| following these <a href="../../../../../../tutorial/main/kb/docs/contributing">contribution guidelines.</a></td> |
| </tr></tbody> |
| </table> |
| </div> |
| </div> |
| <div id="toc" class="toc"> |
| <div id="toctitle"></div> |
| <ul class="sectlevel1"> |
| <li><a href="#_requirements">Requirements</a></li> |
| <li><a href="#_setting_up_the_tutorial_environment">Setting Up the Tutorial Environment</a></li> |
| <li><a href="#_using_predefined_configurations">Using Predefined Configurations</a> |
| <ul class="sectlevel2"> |
| <li><a href="#all">Running All Analyzers</a></li> |
| <li><a href="#hints">Verifying Java Code against NetBeans Java Hints</a></li> |
| <li><a href="#default">Customizing a Default Configuration</a></li> |
| </ul> |
| </li> |
| <li><a href="#_creating_and_deleting_configurations">Creating and Deleting Configurations</a></li> |
| <li><a href="#_running_single_inspections">Running Single Inspections</a></li> |
| <li><a href="#_summary">Summary</a></li> |
| </ul> |
| </div> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>The NetBeans IDE Java Editor has a static code analysis feature, which is a tool for finding potential problems and detecting inconsistencies in your source code.</p> |
| </div> |
| <div class="paragraph"> |
| <p>In this tutorial, you will learn how to perform static analysis of your Java code using NetBeans Java Hints without actually running your applications.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_requirements"><a class="anchor" href="#_requirements"></a>Requirements</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p><strong>To complete this tutorial, you need the following software and resources.</strong></p> |
| </div> |
| <table class="tableblock frame-all grid-all stretch"> |
| <colgroup> |
| <col style="width: 50%;"> |
| <col style="width: 50%;"> |
| </colgroup> |
| <thead> |
| <tr> |
| <th class="tableblock halign-left valign-top">Software or Resource</th> |
| <th class="tableblock halign-left valign-top">Version Required</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://web.archive.org/web/20131021173103/https://netbeans.org/project_downloads/samples/Samples/Java/library.zip">library.zip</a></p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">NetBeans project</p></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_setting_up_the_tutorial_environment"><a class="anchor" href="#_setting_up_the_tutorial_environment"></a>Setting Up the Tutorial Environment</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>In addition to the required software listed above you should have the following installed on your computer:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p>The <a href="https://web.archive.org/web/20131021173103/https://netbeans.org/project_downloads/samples/Samples/Java/library.zip">library.zip</a> file should be unzipped into your NetBeans project folder and opened in the NetBeans IDE.</p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_using_predefined_configurations"><a class="anchor" href="#_using_predefined_configurations"></a>Using Predefined Configurations</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>You can use the following predefined configurations when inspecting your code in the NetBeans IDE:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><a href="#all">All Analyzers</a></p> |
| </li> |
| <li> |
| <p><a href="#hints">NetBeans Java Hints</a></p> |
| </li> |
| <li> |
| <p><a href="#default">Default</a></p> |
| </li> |
| </ul> |
| </div> |
| <div class="sect2"> |
| <h3 id="all"><a class="anchor" href="#all"></a>Running All Analyzers</h3> |
| <div class="paragraph"> |
| <p>The <code>All Analyzers</code> configuration deploys all static code analysis tools available in the IDE.</p> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To run the <code>All Analyzers</code> configuration, complete the following steps:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Choose Source > Inspect from the main IDE’s toolbar.</p> |
| </li> |
| <li> |
| <p>In the Scope drop-down list of the Inspect dialog box, select <code>Current Project (library)</code> .</p> |
| </li> |
| <li> |
| <p>In the Configuration drop-down list, select the <code>All Analyzers</code> configuration.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/allconfig.png"><img src="../../../../_images/kb/docs/java/allconfig-small.png" alt="allconfig small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="4"> |
| <li> |
| <p>Click Inspect. |
| The results of the analysis are displayed in the Inspector Window as a tree view on the left.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/all.png"><img src="../../../../_images/kb/docs/java/all-small.png" alt="all small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>The description of the currently selected in the tree view finding is displayed on the right.</p> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/alldescription.png"><img src="../../../../_images/kb/docs/java/alldescription-small.png" alt="alldescription small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="admonitionblock note"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-note" title="Note"></i> |
| </td> |
| <td class="content"> |
| If you want to leave some part of your code that is reported as problematic as is, the IDE allows you to suppress the warning for this code to leave it without any changes. You can double-click a warning in the tree view of the Inspector Window to go to the Source Editor.<br> |
| Press <span class="keyseq"><kbd>Alt</kbd>+<kbd>Enter</kbd></span>, click the black arrow pointing to the right at the end of the displayed hint, and choose <code>SuppressWarning - <em>(warning name)</em></code> . |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/suppress.png"><img src="../../../../_images/kb/docs/java/suppress-small.png" alt="suppress small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect2"> |
| <h3 id="hints"><a class="anchor" href="#hints"></a>Verifying Java Code against NetBeans Java Hints</h3> |
| <div class="paragraph"> |
| <p>The <code>NetBeans Java Hints</code> configuration available in the IDE enables you to verify if the predefined coding standard rules are satisfied by the source code under consideration. In other words, it applies a set of NetBeans Java Hints (also known as code inspections) to your Java source files.</p> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To run the <code>NetBeans Java Hints</code> configuration, complete the following steps:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Choose Source > Inspect from the main IDE’s toolbar.</p> |
| </li> |
| <li> |
| <p>In the Scope drop-down list of the Inspect dialog box, select <code>Open Projects</code> (if you have only one <code>library</code> project open in the IDE) or <code>Current Project (library)</code> .</p> |
| </li> |
| </ol> |
| </div> |
| <div class="admonitionblock note"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-note" title="Note"></i> |
| </td> |
| <td class="content"> |
| You can define a scope (a file, package, or project(s)) for the <code>NetBeans Java Hints</code> configuration. |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="3"> |
| <li> |
| <p>Select the Configuration radio button and choose <code>NetBeans Java Hints</code> in the drop-down list.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/hints.png"><img src="../../../../_images/kb/docs/java/hints-small.png" alt="hints small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="4"> |
| <li> |
| <p>Click Inspect. |
| The IDE displays the tree view with the results of the analysis with the <code>NetBeans Java Hints</code> configuration in the Inspector Window.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/hintsconfig.png" alt="hintsconfig"> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="5"> |
| <li> |
| <p>In the Inspector Window, click the <a href="#categorize">Categorize</a> button in the toolbar on the left to view the problems grouped into categories.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/catview.png" alt="catview"> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>The following table displays the commands available in the Inspector Window.</p> |
| </div> |
| <table class="tableblock frame-all grid-all stretch"> |
| <colgroup> |
| <col style="width: 33.3333%;"> |
| <col style="width: 33.3333%;"> |
| <col style="width: 33.3334%;"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Icon</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Name</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Function</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"> |
| <p><span class="image"><img src="../../../../_images/kb/docs/java/refreshbutton.png" alt="refreshbutton"></span></p> |
| </div></div></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Refresh</strong></p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Displays a refreshed list of the static analysis results.</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"> |
| <p><span class="image"><img src="../../../../_images/kb/docs/java/upbutton.png" alt="upbutton"></span></p> |
| </div></div></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Previous Problem</strong></p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Displays the previous problem in the list of the static analysis results.</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"> |
| <p><span class="image"><img src="../../../../_images/kb/docs/java/downbutton.png" alt="downbutton"></span></p> |
| </div></div></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Next Problem</strong></p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Displays the following problem in the list of the static analysis results.</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"> |
| <p><span class="image"><img src="../../../../_images/kb/docs/java/categorizebutton.png" alt="categorizebutton"></span></p> |
| </div></div></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Categorize</strong></p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Toggles the collapsed view of the problems detected in a file, project, or package or the categorized view of all the detected problems.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="sect2"> |
| <h3 id="default"><a class="anchor" href="#default"></a>Customizing a Default Configuration</h3> |
| <div class="paragraph"> |
| <p>While working on your code you may need to customize a predefined configuration that includes your own NetBeans Java hints or FindBugs bugs.</p> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To tailor a predefined <code>Default</code> configuration to your own needs, complete the following steps:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Choose Source > Inspect from the main IDE’s toolbar.</p> |
| </li> |
| <li> |
| <p>In the Inspect dialog box, select the Configuration radio button and select the <code>Default</code> configuration.</p> |
| </li> |
| <li> |
| <p>Click Manage. |
| The IDE displays the Configurations dialog box.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/configurations-db.png" alt="configurations db"> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="4"> |
| <li> |
| <p>Ensure <code>Default</code> is selected in the Configurations drop-down list.</p> |
| </li> |
| <li> |
| <p>In the Analyzer drop-down list, select the <code>JRE 8 Profiles Conformance</code> or <code>Netbeans Java Hints</code> analyzer.</p> |
| </li> |
| <li> |
| <p>Depending on the choice of the analyzer in the previous step, select the profile to validate, the inspections, or bugs you need to include into your <code>Default</code> configuration.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/select-inspections.png"><img src="../../../../_images/kb/docs/java/select-inspections-small.png" alt="select inspections small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="7"> |
| <li> |
| <p>Click OK to save your <code>Default</code> configuration.</p> |
| </li> |
| </ol> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_creating_and_deleting_configurations"><a class="anchor" href="#_creating_and_deleting_configurations"></a>Creating and Deleting Configurations</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>You can create and delete your own configurations to be used in the static analysis of your Java code.</p> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To create a configuration, complete the following steps:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Choose Source > Inspect from the main IDE’s toolbar.</p> |
| </li> |
| <li> |
| <p>In the Inspect dialog box, select the Configuration radio button and select the <code>Default</code> configuration.</p> |
| </li> |
| <li> |
| <p>Click Manage.</p> |
| </li> |
| <li> |
| <p>In the Configurations dialog box, click the black arrow at the end of the Configurations drop-down list and choose New.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/newconfig.png" alt="newconfig"> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>A <code>newConfig</code> configuration is created and added to the Configurations drop-down list.</p> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/newconfig-created.png" alt="newconfig created"> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="5"> |
| <li> |
| <p>In the Analyzer drop-down list, choose <code>JRE 8 Profiles Conformance</code> or <code>Netbeans Java Hints</code>.</p> |
| </li> |
| <li> |
| <p>Specify the profile, inspections, or bugs to be included into your own configuration.</p> |
| </li> |
| <li> |
| <p>Click OK to save your edits and close the Configurations dialog box. |
| The created <code>newConfig</code> configuration is available in the Configuration drop-down list of the Inspect dialog box.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/newconfig-inspect.png"><img src="../../../../_images/kb/docs/java/newconfig-inspect-small.png" alt="newconfig inspect small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="admonitionblock note"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-note" title="Note"></i> |
| </td> |
| <td class="content"> |
| To rename a configuration, select the <code>newConfig</code> configuration in the Configurations drop-down list, click the black arrow at the end of the Configurations drop-down list and choose Rename. Type a new name (for example, <code>renamedConfig</code> ) and press <kbd>Enter</kbd> to save your edits. |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/renamedconfig.png" alt="renamedconfig"> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To delete a configuration, complete the following steps:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Choose Source > Inspect from the main IDE’s toolbar.</p> |
| </li> |
| <li> |
| <p>In the Inspect dialog box, select the Configuration radio button and select the configuration to be deleted ( <code>renamedConfig</code> in this example).</p> |
| </li> |
| <li> |
| <p>Click Manage.</p> |
| </li> |
| <li> |
| <p>In the Configurations dialog box, click the black arrow at the end of the Configurations drop-down list and choose Delete.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/delete.png" alt="delete"> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic" start="5"> |
| <li> |
| <p>In the Delete Configuration dialog box, click Yes to confirm the deletion of the configuration.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/delete-confirm.png" alt="delete confirm"> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>The <code>renamedConfig</code> configuration is deleted from the Configurations list.</p> |
| </div> |
| <div class="admonitionblock note"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-note" title="Note"></i> |
| </td> |
| <td class="content"> |
| Refer to the <a href="../../../../tutorials/nbm-java-hint/" class="xref page">NetBeans Java Hint Module Tutorial</a> for information on how to create a NetBeans module that provides one or more NetBeans Java hints. |
| </td> |
| </tr> |
| </table> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_running_single_inspections"><a class="anchor" href="#_running_single_inspections"></a>Running Single Inspections</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>You can inspect your code for a particular deficiency in your source code using the static code analysis feature in the NetBeans IDE.</p> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To detect a specific inconsistency or problem in your Java source code with a single inspection, complete the following steps:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Choose Source > Inspect from the main IDE’s menu.</p> |
| </li> |
| <li> |
| <p>In the Scope drop-down list of the Inspect dialog box, select a file, package, or project(s) to be inspected.</p> |
| </li> |
| <li> |
| <p>Select Single Inspection and do either of the following:</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock"> |
| <div class="content"> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p>In the Single Inspection drop-down list, scroll and select a <em>single</em> NetBeans Java hint or FindBugs bug to be used in the source code analysis, or</p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/single-inspection.png"><img src="../../../../_images/kb/docs/java/single-inspection-small.png" alt="single inspection small"></a> |
| </div> |
| </div> |
| <div class="openblock"> |
| <div class="content"> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p>Click Browse to open the Configurations dialog box and, in the Analyzer drop-down list, specify the analyzer and then choose a profile (for the JRE 8 Profile Compliance analyzer), a <em>single</em> inspection (for the NetBeans Java Hints analyzer), or a <em>single</em> bug (for the FindBugs analyzer) to be used in the source code analysis. Click OK to close the Configurations dialog box.</p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/hint-inspection.png"><img src="../../../../_images/kb/docs/java/hint-inspection-small.png" alt="hint inspection small"></a> |
| </div> |
| </div> |
| <div class="openblock"> |
| <div class="content"> |
| <div class="olist arabic"> |
| <ol class="arabic" start="4"> |
| <li> |
| <p>In the Inspect dialog box, click Inspect to perform the source code analysis. |
| After the Inspect operation is completed, the hints that can be applied to your code or bugs that have been found are displayed in the Inspector Window below the Source Editor.</p> |
| </li> |
| </ol> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_summary"><a class="anchor" href="#_summary"></a>Summary</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>This tutorial covers most frequent usages of the static code analysis feature in the NetBeans IDE. Please note that with the static code analysis functionality you can also perform custom refactorings at a project scope, or apply particular refactoring configurations to several projects open in the IDE, etc.</p> |
| </div> |
| <div class="paragraph"> |
| <p><a href="#top">top</a></p> |
| </div> |
| </div> |
| </div> |
| <section class='tools'> |
| <ul class="menu align-center"> |
| <li><a title="Facebook" href="https://www.facebook.com/NetBeans"><i class="fa fa-md fa-facebook"></i></a></li> |
| <li><a title="Twitter" href="https://twitter.com/netbeans"><i class="fa fa-md fa-twitter"></i></a></li> |
| <li><a title="Github" href="https://github.com/apache/netbeans"><i class="fa fa-md fa-github"></i></a></li> |
| <li><a title="YouTube" href="https://www.youtube.com/user/netbeansvideos"><i class="fa fa-md fa-youtube"></i></a></li> |
| <li><a title="Atom Feed" href="https://netbeans.apache.org/blogs/atom"><i class="fa fa-mf fa-rss"></i></a></li> |
| <li><a title="Slack" href="https://tinyurl.com/netbeans-slack-signup/"><i class="fa fa-md fa-slack"></i></a></li> |
| <li><a title="Issues" href="https://github.com/apache/netbeans/issues"><i class="fa fa-mf fa-bug"></i></a></li> |
| </ul> |
| <ul class="menu align-center"> |
| <li><a href="https://github.com/apache/netbeans-antora-tutorials/edit/main/modules/ROOT/pages/kb/docs/java/code-inspect.adoc" title="See this page in github"><i class="fa fa-md fa-edit"></i> See this page in GitHub.</a></li> |
| </ul> |
| </section> |
| </article> |
| </div> |
| <div class='grid-container incubator-area' style='margin-top: 64px'> |
| <div class='grid-x grid-padding-x'> |
| <div class='large-auto cell text-center'> |
| <a href="https://www.apache.org/"> |
| <img style="height: 60px" title="Apache Software Foundation" src="../../../../../../_/images/asf_logo_wide.svg" /> |
| </a> |
| </div> |
| <div class='large-auto cell text-center'> |
| <a href="https://www.apache.org/events/current-event.html"> |
| <img style="width:234px; height: 60px;" title="Apache Software Foundation current event" src="https://www.apache.org/events/current-event-234x60.png"/> |
| </a> |
| </div> |
| </div> |
| </div> |
| <footer> |
| <div class="grid-container"> |
| <div class="grid-x grid-padding-x"> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/about">About</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/community/who">Who's Who</a></li> |
| <li><a href="https://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| <li><a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> |
| <li><a href="https://www.apache.org/security/">Security</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/community">Community</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/community/mailing-lists">Mailing lists</a></li> |
| <li><a href="../../../../../../front/main/community/committer">Becoming a committer</a></li> |
| <li><a href="../../../../../../front/main/community/events">NetBeans Events</a></li> |
| <li><a href="https://www.apache.org/events/current-event.html">Apache Events</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/participate">Participate</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/participate/submit-pr">Submitting Pull Requests</a></li> |
| <li><a href="../../../../../../front/main/participate/report-issue">Reporting Issues</a></li> |
| <li><a href="../../../../../../front/main/participate/#documentation">Improving the documentation</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/help">Get Help</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/help/#documentation">Documentation</a></li> |
| <li><a href="../../../../../../wiki/main/wiki">Wiki</a></li> |
| <li><a href="../../../../../../front/main/help/#support">Community Support</a></li> |
| <li><a href="../../../../../../front/main/help/commercial-support">Commercial Support</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/download">Download</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/download">Releases</a></li> |
| <li><a href="https://plugins.netbeans.apache.org/">Plugins</a></li> |
| <li><a href="../../../../../../front/main/download/#_daily_builds_and_building_from_source">Building from source</a></li> |
| <li><a href="../../../../../../front/main/download/#_older_releases">Previous releases</a></li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </footer> |
| <div class='footer-disclaimer'> |
| <div class="footer-disclaimer-content"> |
| <p>Copyright © 2017-2025 <a href="https://www.apache.org">The Apache Software Foundation</a>.</p> |
| <p>Licensed under the Apache <a href="https://www.apache.org/licenses/">license</a>, version 2.0</p> |
| <div style='max-width: 40em; margin: 0 auto'> |
| <p>Apache, Apache NetBeans, NetBeans, the Apache feather logo and the Apache NetBeans logo are trademarks of <a href="https://www.apache.org">The Apache Software Foundation</a>.</p> |
| <p>Oracle and Java are registered trademarks of Oracle and/or its affiliates.</p> |
| <p>The Apache NetBeans website conforms to the <a href="https://privacy.apache.org/policies/privacy-policy-public.html">Apache Software Foundation Privacy Policy</a></p> |
| </div> |
| </div> |
| </div> |
| |
| |
| <script src="../../../../../../_/js/vendor/lunr.js"></script> |
| <script src="../../../../../../_/js/search-ui.js" id="search-ui-script" data-site-root-path="../../../../../.." data-snippet-length="100" data-stylesheet="../../../../../../_/css/search.css"></script> |
| <script async src="../../../../../../search-index.js"></script> |
| <script src="../../../../../../_/js/vendor/jquery.min.js"></script> |
| <script src="../../../../../../_/js/vendor/what-input.min.js"></script> |
| <script src="../../../../../../_/js/vendor/foundation.min.js"></script> |
| <script src="../../../../../../_/js/vendor/jquery.colorbox-min.js"></script> |
| <script src="../../../../../../_/js/netbeans.js"></script> |
| <script> |
| $(function(){ $(document).foundation(); }); |
| </script> |
| <script src="../../../../../../_/js/vendor/highlight.min.js"></script> |
| <script> |
| document.addEventListener('DOMContentLoaded', (event) => { |
| document.querySelectorAll('pre code').forEach((el) => { |
| hljs.highlightElement(el); |
| }); |
| }); |
| </script> |
| </body> |
| </html> |