{"id":24315394,"url":"https://github.com/fabianexe/go2jenkins","last_synced_at":"2026-04-18T22:32:23.853Z","repository":{"id":203785382,"uuid":"710398725","full_name":"Fabianexe/go2jenkins","owner":"Fabianexe","description":"Create coverage files for golang that the Jenkins coverage plugin can read and display.","archived":false,"fork":false,"pushed_at":"2024-05-25T17:41:16.000Z","size":84,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-07T18:02:42.721Z","etag":null,"topics":["coverage","golang","hacktoberfest","jenkins"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fabianexe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-26T16:00:21.000Z","updated_at":"2026-03-16T22:11:26.000Z","dependencies_parsed_at":"2025-01-17T11:25:23.063Z","dependency_job_id":null,"html_url":"https://github.com/Fabianexe/go2jenkins","commit_stats":null,"previous_names":["fabianexe/go-jenkins-coverage"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/Fabianexe/go2jenkins","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fabianexe%2Fgo2jenkins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fabianexe%2Fgo2jenkins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fabianexe%2Fgo2jenkins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fabianexe%2Fgo2jenkins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fabianexe","download_url":"https://codeload.github.com/Fabianexe/go2jenkins/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fabianexe%2Fgo2jenkins/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31987799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"ssl_error","status_checked_at":"2026-04-18T20:23:29.375Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coverage","golang","hacktoberfest","jenkins"],"created_at":"2025-01-17T11:15:13.961Z","updated_at":"2026-04-18T22:32:23.823Z","avatar_url":"https://github.com/Fabianexe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go2jenkins\n![Create Jenkins coverage files for golang](./img/logo.png \"Create Jenkins coverage files for golang\")\n\nCreate coverage files for golang that the Jenkins coverage plugin can read and display.\nIncluding complexity metrics and branch coverage.\n\n## Installation\nSimple install it by `go install`:\n```\ngo install https://github.com/Fabianexe/go2jenkins@latest\n```\n\n## Usage\n`go2jenkins` can be run without any arguments.\nHowever, this means that it will for sources in the current directory, \ndo not add coverage data and write a `coverage.xml` in the current directory.\n\nSo some flags exists to change this behavior:\n### Flags\n* `-h` or `--help` to get a help message\n* `-s` or `--source` to specify the source directory\n* `-c` or `--coverage` to specify the coverage profile as written by `go test -coverprofile`\n* `-o` or `--output` to specify the output file\n* `-v` or `--verbose` to get more output. Can be used multiple times to increase the verbosity\n\nBeside these flags, the following flags can be used to change the behavior of the coverage report:\n* `--cyclomatic` to use cyclomatic complexity metrics (default is cognitive complexity)\n* `--generatedFiles` to include generated files in the coverage report \n* `--noneCodeLines` to include none code lines in the coverage report \n* `--errorIf` to include error ifs in the coverage report \n\n### Example\n```\ngo2jenkins -s ./src -c ./coverage.out -o ./coverage.xml\n```\nThis will create a coverage report for the sources in the `./src` directory,\nusing the coverage profile `./coverage.out` and write the report to `./coverage.xml`.\n\n## The accuracy of `go test -coverprofile`\nThe `go test -coverprofile` command is a great tool to get coverage information about your project.\nHowever, it measures the coverage on a bock level. This means that if you function contains empty lines, only comments,\nor lines with only a closing bracket, they will be counted in line metrics.\n\nThis project tries to solve this problem by using the `go/ast` package to determine the actual lines of code from the source.\n\nAnother result from this is that branches on a line level can be determined. If a line contains an `if` statement,\nwith multiple conditions, it is still one block for the coverage profile. There are projects that try to solve this problem\nfor example [gobco](https://github.com/rillig/gobco). However, they for the moment not compatible with the Jenkins coverage plugin.\nThus, we add branch coverage on method and file level. Where such multi condition statements are counted as one branche.\n\n## Source code Filter\nThere are parts of the source code that are not included in the coverage report.\nAt the moment, the following parts are excluded:\n* Generated files\n    * Files that have a comment that includes `Code generated by` before the package keyword are excluded\n* None code lines\n    * Empty lines\n    * Lines that only contain a comment\n    * Lines that only contain a closing bracket\n* Error ifs\n    * If statements that only contain an error check (`if err != nil`) with only a return in the body are excluded\n\nYou can deactivate these filters by using the corresponding flags.\n\nSure, here is the information in Markdown format:\n\n## Cyclomatic Complexity vs Cognitive Complexity\n\nCyclomatic Complexity and Cognitive Complexity are both software metrics used to measure the complexity of a program. They are used to determine the quality of code and identify areas that might need refactoring. However, they approach the measurement of complexity from different perspectives.\n\n### Cyclomatic Complexity\n\nCyclomatic Complexity, introduced by Thomas McCabe in 1976, is a quantitative measure of the number of linearly independent paths through a program's source code. It is computed using the control flow graph of the program. The cyclomatic complexity of a section of source code is the count of the number of linearly independent paths through the source code. It is computed as:\n\n```\nCyclomatic Complexity = Edges - Nodes + 2*Connected Components\n```\n\nCyclomatic Complexity is primarily used to evaluate the complexity and understandability of a program, and it can also give an idea of the number of test cases needed to achieve full branch coverage.\n\n### Cognitive Complexity\n\nCognitive Complexity, introduced by SonarSource, is a measure that focuses on how difficult the code is to understand by a human reader. It considers things like the level of nesting, the number of break or continue statements, the number of conditions in a decision point, and the use of language structures that unnecessarily increase complexity.\n\nCognitive Complexity aims to produce a measurement that will correlate more closely with a developer's experience of a code base, making it easier to identify problematic areas of code that need refactoring.\n\n### Summary\n\nIn summary, while Cyclomatic Complexity is a measure of the structural complexity of a program, Cognitive Complexity is a measure of how difficult a program is to understand by a human reader. \nBoth are useful, but they serve different purposes and can lead to different conclusions about the code's quality.\n\nBy default `go2jenkins` uses Cognitive Complexity. You can change this behavior by using the `--cyclomatic` flag.\n\n## Others\nSo far we are aware about two other projects that do something similar:\n* [gocov-xml](https://github.com/AlekSi/gocov-xml)\n* [gocover-cobertura](https://github.com/boumenot/gocover-cobertura)\n\nHowever, both of them focus on the coverage part and take over a big downsides of the `go test -coverprofile` command.\nOnly packages with any coverage are included in the report ([will be fixed in go](https://go-review.googlesource.com/c/go/+/495447)).\nThis means that if you have a package with no tests at all, it will not be included in the report.\nThis is a big problem if you want to have a complete report of your project or any meaningfully coverage metrics.\n\nFurther this project is more about the Jenkins integration. So it is more than just a coverage tool.\nIt adds complexity metrics, more options to determine coverage, and branch coverage.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabianexe%2Fgo2jenkins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabianexe%2Fgo2jenkins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabianexe%2Fgo2jenkins/lists"}