SonarSource-Demos / sonar-golc

GoLC counts physical lines of source code in numerous programming languages supported by the Developer, Enterprise, and Data Center editions of SonarQube across your Bitbucket Cloud, Bitbucket Data Center, GitHub, GitLab, and Azure DevOps repositories.
MIT License
5 stars 0 forks source link

Missing repositories after scan #4

Open wolframite opened 1 month ago

wolframite commented 1 month ago

When I'm scanning our GitHub organization I can see a lot of 404 errors which result in up to half of the repositories missing in the final report. When I define the repository in the config.json file however everything works as expected.

I tried running it on different platforms: AMD64 on AWS (Linux) and ARM64 on my MacBook. I also disabled multithreading and set the amount of workers to 1 without any change to the result. To exclude the organization as the culprit we ran the program on 3 different ones and got the same outcome.

This is the output of our scan run:

$ ./golc -devops Github
INFO[0000] βœ… Configuration loaded successfully and version matched!
[2024-09-16 20:13:17] INFO βœ… Using configuration for DevOps platform 'Github'

[2024-09-16 20:13:17] INFO πŸ”Ž Analysis of devops platform objects ...

 Repos saved successfully!
[2024-09-16 20:13:26] INFO    βœ… The number of Repo(s) found is: xxx

Get Repo(s)...β–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’[2024-09-16 20:13:28] ERROR Error fetching commits for branch feature/AAAAA-714/create-sqs-policy: GET https://api.github.com/repos/<organization>/<repository>/commits?per_page=100&sha=feature%2FAAAAA-714%2Fcreate-test-LIVE&since=2024-08-16T20%3A13%3A28%2B02%3A00: 404 Not Found []

       Analysis top branch(es) in repository <repository> ...β–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’[2024-09-16 20:13:29] ERROR Error fetching commits for branch feature/AAAAA-714/create-test-LIVE: GET https://api.github.com/repos/<organization>/<repository>/commits?per_page=100&sha=feature%2FAAAAA-714%2Fcreate-test-LIVE&since=2024-08-16T20%3A13%3A28%2B02%3A00: 404 Not Found []

       Analysis top branch(es) in repository <repository> ...β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’[2024-09-16 20:13:29] ERROR Error fetching commits for branch feature/AAAAA-714/create-test-LIVE: GET https://api.github.com/repos/<organization>/<repository>/commits?per_page=100&sha=feature%2FAAAAA-714%2Fcreate-test-LIVE&since=2024-08-16T20%3A13%3A28%2B02%3A00: 404 Not Found []

When I open the URLs in the browser they work without a problem.

sylvain-combe-sonarsource commented 1 month ago

Thanks for reporting this problem @wolframite We are looking into it.

Meanwhile - since the 404 errors you quoted come from fetching data from feature branches - you may try the default_branch parameter which will target the main branch for all projects. And let us know.

wolframite commented 1 month ago

Thanks for looking into this, let me know if I can provide any data for your investigation. I just checked my config.json and the DefaultBranch parameter is already set to true. Setting it to false does exactly the same, so it looks like it's ignored. Setting the branch to main and DefaultBranch to false also doesn't seem to be picked up.

      "Github": {
        "Users": "",
        "AccessToken": "ghp_ABC123MyValidGitHubKeyTestTest1234",
        "Organization": "example-org",
        "DevOps": "github",
        "Project": "",
        "Repos": "",
        "Branch": "",
        "DefaultBranch": true,
        "Url": "https://api.github.com/",
        "Apiver": "2022-11-28",
        "Baseapi": "github.com",
        "Protocol": "https",
        "FileExclusion":".cloc_github_ignore",
        "ExtExclusion":[],
        "ExcludePaths":[],
        "Period":-1,
        "Factor":33,
        "Multithreading":true,
        "Stats": false,
        "Workers": 10 ,
        "NumberWorkerRepos":10,
        "ResultByFile": false,
        "ResultAll": true,
        "Org":true
      },