I'm doing an internship into a small company which is working on part of a systems which runs on a base already written by another company (many company are working on the same project) which is basically a 1:1 translation from an old COBOL system into .NET technology. Since they have not been given enough time, they're literally running producing as much working code as possible, so the code quality is not elevated. The objective of my internship is to produce a graduate thesis following my work in this little company, and will be based on refactoring some functions or classes (between those being developed in this small company) following the baselines of software engineering (patterns mainly), the branch to whom my thesis is related.

To underline the results of this work, my professor told me to use a static code analyzer such SonarQube or Kiuwan, I already configured and hosted on Amazon AWS a functioning SonarQube 7.4 server.

At this point of my work the question is: how can I analyze just this single class alone? Pro and Cons.

I'm in front of 2 choices:

1) Create a project in Visual Studio to make this class self-sustaining full of stubs and mocks to make it live by itself with the pourpose of being analyzed before and after the re-engineering.

--> The main issue with this option is that this class on which I am working is made of about 12000 lines of code, so it's easy to think that it refers to many many other classes, thus creating stubs and mocks would be a pain...

2) Use an integrated feature in SonarQube, which should let exclude whole folders or analyze just selected files/folders.

--> I already analyzed the whole project, made of about 350k lines of code using the default SonarQube rules, it gave me a result in everyone of it's fields (quality, bugs, security...), the problem is that even modifing and making this class (on which I am working) a diamond of engeneering, it wouldn't change much the overall quality of the software (obviously).

The structure:

The project has three indipendent branches: Backend, Client, and DB communications, I'm working in the Backend part.

The Backend got its own .sln file (the one I used for the whole analysis of the project in SonarQube), which links to .csproj subprojects. I feeded SonarQube one of these .csproj and it was able to analyze it.

Applying option 2 :

In the Sonar server in the preferences of the project, there's a tab in which you can exclude what you DON'T want to be analyzed and INCLUDE JUST what you want to analyze. Since I was interested in the second option, I inserted in the field sonar.inclusions the name of the class I want to be analyzed, then I builded the project, sent the blob to SonarQube server, which analyzed it and...nothing happened, in the project page of Sonar just appeared "No project Analyzed yet".

So my questions are:

Question 1) Should I follow this way of analyzing a single class with SonarQube? By directly feeding it from the original bug project, or is it better to extract the class, place it into a new project and fulfill it with stubs and mocks? Considering the complexity of doing this.

Question 2) Following what I wrote above, how can make sonar analyze just the class I feeded? Is practically possible to do it? What did I do wrong?

I posted the same question to stackoverflow, but they told me to post it here!

Thanks in advance for all the help you will give me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.