Step By Step | Simply Install SonarQube Locally And Test | Code Quality Analysis | .NET Core

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] in this video we are going to look at how we can install sonar cube locally and how can we verify the quality of our code so the first thing is to download the java development kit so let's head down to the oracle website so let's start downloading the installer all right now that we have successfully downloaded the installer now let's install the java development kit click on next now here just copy the location that we are going to install the jdk [Music] so let's copy it all right click on next and now that the jdks got installed the next step is to set the global path so open the start menu and search for advanced system settings [Music] click on environment variables and just double click on path now here we are going to add a new path and let's paste whatever we have copied from the jdk installer all right now this is the path where the jdk installer resides click on ok click on ok all right now next we need to download the sonar cube so let's head down to the sonarqube website click on download and from here we can download the community edition now let's download the ship package [Music] all right the next step is to unzip the binaries [Music] now let's place the zip into a proper folder [Music] let's create a folder here and we can name it sonar server [Music] let's place the zip over here and let's extract it [Music] now let's go to the bin folder now since i'm using windows let's go to the windows 32 or 64 bit folder and here we need to run the starts on our dot bat file so let's run the sonar bat locally all right now it's look like the sonar server is running [Music] now if the windows defender fiber pops up just click on allow all right now it seems like the elastic search is running on nine zero zero one port and so on the server is running on nine zero zero port so let's see whether the elastic server is running so let's open a browser and go to nine zero zero one so the elastic server is running over here let's head down to sonar cube on 9000 port [Music] now we are on the login page here we can use the default credential which is admin for both username and password click on login alright now it will ask to change the password so put the old password as admin and choose a new password all right now that we have set up the sonar cube now let's setup a source code for our dotnet application open the visual studio and create a new project [Music] i am going to name this project as test tab [Music] click on next let's try to run the project all right it's running and here is the source code of our project [Music] so the next step is to register our project on the sonar cube so let's open the sonar cube and click on manually since our application name is desktop just put desktop over here click on next and here it's asking where to find the code so we can say locally and we can generate a token so put something like analyze the test tab and generate your token [Music] all right now let's copy the token [Music] the next thing that we need to do is install the sonar scanner for c sharp so click on continue select dotnet select.net core the first command can install sound scanner for ms build now let's run this command so that it can install the sonar scanner tool globally [Music] all right now that we have installed the sonar scanner tool [Music] now let's go to the project and open the terminal over there and first run the first command [Music] now this command can generate few of the files which includes some members build dlls now let's create our first demo program that can print from 1 to 100. now let's intentionally put some bad coding practices over here let's create a test variable and let's not use it also let's create a try case statement where we catch where we have the exception in ex and we are not using it as well as we are just simply throwing out the exception [Music] all right now let's run it so even though our program works the coding standard is very bad there are kodi standard issues so now so now let's do a scan so just build it using the dot net build command all right now let's scan it using the date command so let's copy the third command and execute [Music] now as the scanning completes we can see a report on the website and it says the gate is first but we have four course mills let's go to the code tab open the program.cs and here we can see where all our code smells are so here we are using a test but we are not using that variable so it's an unused variable here we are using an exception ex but we are not use the ex variable here we are simply throwing out the exception alright now let's accept the solder cube suggestions and clean our code all right now that we have clean our code let's run it and it is running properly now let's scan it again [Music] and now we got an error and the error says line 5 is out of range but our program has only 4 lines [Music] this is happening because we are changing the code between the start and end commands so in order to run the test again we have to again run the three commands [Music] [Music] all right now we have no errors now let's go to the sonar cube again open it again now we have zero code smudge all right [Music] so this is the new code and this is the overall code so let's see the graph so here we have the fourth so here we have four code smarts as well as here we have zero all right now here's a tip so instead of running three different commands let's combine these three different commands into a single bad file open the root folder and create a new text file [Music] and here let's paste all our three commands and once we have all the three commands let's save the file close it and let's rename the file and change the extension from txt to b80 so now that it becomes a bad file now let's change the code a little bit and add some code smells to simulate a bad coding practice [Music] now instead of running the three commands we can simply double click on this bad file when we need to generate a report let's get back into the sonar dashboard now here it's not updated so let's refresh our page all right now we got a test failure why because previously our test was success and now we are again making code smells and here just go to the code and you can now find now find all our latest code over here with the corresponding issues so this is how we can install sonar cube locally and validate our code thank you so much [Music]
Info
Channel: The Code Switch
Views: 14,002
Rating: undefined out of 5
Keywords: azure, cloud, microsoft, free, subscription
Id: lOY8oWQxG-E
Channel Id: undefined
Length: 11min 24sec (684 seconds)
Published: Sun Jan 09 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.