{"id":74,"date":"2011-12-23T15:53:34","date_gmt":"2011-12-23T14:53:34","guid":{"rendered":"http:\/\/dev.qualilogy.com\/en\/?p=74"},"modified":"2013-01-04T15:54:55","modified_gmt":"2013-01-04T14:54:55","slug":"sonar-first-analysis","status":"publish","type":"post","link":"http:\/\/qualilogy.com\/en\/sonar-first-analysis\/","title":{"rendered":"Sonar &#8211; First analysis"},"content":{"rendered":"<p>We have seen in the previous post <a title=\"Sonar Installation\" href=\"http:\/\/qualilogy.com\/en\/sonar-installation\" target=\"_blank\">how to install Sonar and its Java Runner<\/a>. This last one allows us to realize analysis without using tools like Maven or Ant.<\/p>\n<p>In this post, we will present how to do a first analysis on Mainframe-Cobol source code.<\/p>\n<p><!--more--><\/p>\n<p>Let&#8217;s remember that:<\/p>\n<ul>\n<li>The <strong>sonar-runner.properties<\/strong> file is dedicated to the connexion to Sonar and our database<\/li>\n<li>We launch an analysis with the <strong>sonar-runner.bat<\/strong> file.<\/li>\n<\/ul>\n<h3><span style=\"text-decoration: underline;\">Analysis environment<br \/>\n<\/span><\/h3>\n<p>When you install a server of code analysis, it is important to differentiate correctly the different spaces you will be using, according to their object:<\/p>\n<ul>\n<li>A space dedicated to the various software and their different versions: Oracle, Java, Tomcat, Sonar, etc.<\/li>\n<li>The space dedicated to the delivery and the installation of the source code to analyze.<\/li>\n<li>The space dedicated to the implementation of analyses: configuration, backups, customization, creation of reports, extraction of data, documentation of your analyses (useful when you begin to get a lot of different ones, or when you have to get back to an old one, or different people operate the analysis server), etc.<\/li>\n<\/ul>\n<p>Sonar allows us to specify this space in the <strong>sonar-runner.bat<\/strong>, with the <strong>PROJECT_HOME<\/strong> variable. We are thus going to look into this file for the following line:<\/p>\n<p style=\"padding-left: 30px;\"><strong>set PROJECT_HOME=%CD%<\/strong><\/p>\n<p>and modify it to indicate a sub-directory <strong>\\Projets<\/strong> in which I will put the configuration file of my analysis. Really, I would not recommand to place this space under the directory of the Java Runner, it is only for the needs of our demonstration.<\/p>\n<p>So, I modified this sonar-runner.bat file in order to insert the following three lines:<\/p>\n<ul>\n<li>Display the directory of the Java Runner <strong>SONAR_RUNNER_HOME<\/strong>:<\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"><strong>echo &#8220;SONAR_RUNNER_HOME = %SONAR_RUNNER_HOME%&#8221;<\/strong><\/p>\n<ul>\n<li>Define the analysis space <strong>PROJECT_HOME<\/strong> as the sub-directory <strong>\\Projets<\/strong> under the previous folder, and display it:<\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"><strong>set PROJECT_HOME=%SONAR_RUNNER_HOME%\\Projects<\/strong><br \/>\n<strong>echo &#8220;PROJECT_HOME = %PROJECT_HOME%&#8221;<\/strong><\/p>\n<h3><span style=\"text-decoration: underline;\">Configuration of our first analysis<br \/>\n<\/span><\/h3>\n<p>In order to realize an analysis, the Java Runner uses the <strong>sonar-project.properties<\/strong> file located in our environment of analysis. Here we have for objective to analyze some Cobol programs we placed in a directory C:\\SRC\\Mainframe.<\/p>\n<p>Without detailing all the available parameters for such an analysis, we are going to create our file sonar-project.properties with the following attributes:<\/p>\n<ul>\n<li>First, the mandatory data: name and key for this application \/ first analysis, with a version number:<\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"># required metadata<br \/>\n<strong>sonar.projectKey=CBL_1<\/strong><br \/>\n<strong>sonar.projectName=Cobol 1st Analysis<\/strong><br \/>\n<strong>sonar.projectVersion=1.0<\/strong><\/p>\n<ul>\n<li>Localization of the files to analyze:<strong><\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"><strong>sources=C:\/SRC\/Mainframe<\/strong><\/p>\n<ul>\n<li>Last parameter: the programming language for this application:<\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">#The value of the property must be the key of the language.<br \/>\n<strong>sonar.language=cobol<\/strong><\/p>\n<h3><span style=\"text-decoration: underline;\">Run the first analysis<br \/>\n<\/span><\/h3>\n<p>In a DOS command window, we launch the <strong>sonar-runner.bat<\/strong>:<\/p>\n<ul>\n<li>First are displayed the 2 variables designing the directory of the Java Runner and our analysis space: <a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-490\" title=\"JavaRunnerDos1\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos1.jpg\" alt=\"\" width=\"649\" height=\"152\" \/><\/a>With the directory where is located the source code:<a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos21.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-493\" title=\"JavaRunnerDos2\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos21.jpg\" alt=\"\" width=\"650\" height=\"51\" \/><\/a><\/li>\n<\/ul>\n<ul>\n<li>And every possible error (here, an incorrect character chain into the Cobol source code):<a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-495\" title=\"JavaRunnerDos3\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos3.jpg\" alt=\"\" width=\"650\" height=\"80\" \/><\/a><\/li>\n<li>Thanks to Sonar, a syntax error in our Cobol code will not stop it and soon, the &#8216;Analysis successfull&#8217; message is displayed: <a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos4.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-497\" title=\"JavaRunnerDos4\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/JavaRunnerDos4.jpg\" alt=\"\" width=\"649\" height=\"52\" \/><\/a><\/li>\n<\/ul>\n<p>We now can go to the Sonar portal and see the results of our first analysis: <a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/Sonar1stAnalysisResult1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-498\" title=\"Sonar1stAnalysisResult1\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/Sonar1stAnalysisResult1.jpg\" alt=\"\" width=\"889\" height=\"200\" \/><\/a><\/p>\n<p>We could realize our first analysis successfully and in the simplest possible way, with the configuration of some parameters in the <strong>sonar-project.properties<\/strong>, without the need to manage Maven files, whose syntax is sometimes long and complex.<\/p>\n<p>However, the approach described here presents two inconveniences:<\/p>\n<ul>\n<li>The Java Runner works only with the <strong>sonar-project.properties<\/strong> file. Rename this one and the Java Runner will not work correctly anymore. It is thus necessary to modify this file every time we want to do a new analysis.<\/li>\n<li>Checking the possible errors in a DOS window is not very friendly, especially for long analysis and \/ or with a lot of errors.<\/li>\n<\/ul>\n<p>We will see in our <a title=\"Jenkins - Installation\" href=\"http:\/\/qualilogy.com\/en\/jenkins-installation\">next post<\/a> how to improve our analysis server, with the help of our friend Jenkins.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have seen in the previous post how to install Sonar and its Java Runner. This last one allows us to realize analysis without using tools like Maven or Ant. In this post, we will present how to do a first analysis on Mainframe-Cobol source code.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-sonar-installation"],"_links":{"self":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/74"}],"collection":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":1,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":75,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/74\/revisions\/75"}],"wp:attachment":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}