The main branch has no lines of code.2

How do I fix this error? There’s clearly code in the repo. I pushed a non main branch and it created the project in Sonarqube but it gives this error when there’s clearly code in the project. Please fix this error.

I tried everything here but it doesn’t work.

Hi,

Welcome to the community!

Please don’t expect community members to cross-reference your Stackoverflow post. If you’d like to get help here, then you’ll need to post - fully - here.

 
Ann

I didn’t post to stackoverflow. I just tried the answers there and they didn’t work. I want to fix error “The main branch has no lines of code.”

Do i have to push sonar-project.properties to master branch. I’m pushing only a feature branch now. Sonarqube created the project when I pushed, and it gets updated when I push but it doesn’t see any code for some unknown reason. Don’t know what to do the error doesn’t even say where it looked. I don’t understand why it can’t see any code when it’s right there. Do I have to update Jenkins file.

Hi,

Can you post your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

That looks for sonarqube at localhost:9000. I don’t and can’t have sonarqube running on my localhost.

Hi,

Are you saying that when you looked at your analysis log, you found an error about localhost? If so, you can use sonar.host.url to set a non-default SonarQube location.

 
HTH,
Ann

I already tried setting sonar.host.url to the same URL I use to see the projects. I also set sonar.login and sonar.password with the credentials I use to login to sonar.host.url/session/new but it still doesn’t work I only get Unauthorized. Idk if there’s some special API URL i have to use or something.

Hi,

If you’re getting ‘unauthorized’ then the credentials aren’t being passed properly or they’re not the correct credentials.

 
:woman_shrugging:
Ann

I put single quotes are the credentials and now it gives error “You’re not authorized to run analysis. Please contact the project administrator.”

Hi,

So when you put quotes around the token value, you get an immediate(?) authorization error, and when you don’t it comes later?

Without the analysis log I asked for last week, it’s really hard to help you further.

 
Ann