{"id":21743288,"url":"https://github.com/MangoTheCat/cyclocomp","last_synced_at":"2025-07-18T23:30:42.052Z","repository":{"id":45087973,"uuid":"51755668","full_name":"MangoTheCat/cyclocomp","owner":"MangoTheCat","description":"Cyclomatic complexity of R functions and expressions","archived":false,"fork":false,"pushed_at":"2023-05-17T12:18:28.000Z","size":36,"stargazers_count":48,"open_issues_count":11,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-06T21:51:41.938Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MangoTheCat.png","metadata":{"files":{"readme":"README.Rmd","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}},"created_at":"2016-02-15T13:00:31.000Z","updated_at":"2024-11-13T19:10:31.000Z","dependencies_parsed_at":"2024-04-11T20:49:13.697Z","dependency_job_id":"d5fb4e09-c08e-439a-adc9-cd6028611e85","html_url":"https://github.com/MangoTheCat/cyclocomp","commit_stats":{"total_commits":48,"total_committers":3,"mean_commits":16.0,"dds":"0.10416666666666663","last_synced_commit":"8ac6139b3c8ffd4fdb4941a6d94c6d34a848e6ea"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MangoTheCat/cyclocomp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MangoTheCat%2Fcyclocomp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MangoTheCat%2Fcyclocomp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MangoTheCat%2Fcyclocomp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MangoTheCat%2Fcyclocomp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MangoTheCat","download_url":"https://codeload.github.com/MangoTheCat/cyclocomp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MangoTheCat%2Fcyclocomp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265853183,"owners_count":23839124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-26T07:04:01.880Z","updated_at":"2025-07-18T23:30:41.524Z","avatar_url":"https://github.com/MangoTheCat.png","language":"R","readme":"\n```{r, setup, echo = FALSE, message = FALSE}\nknitr::opts_chunk$set(\n  comment = \"#\u003e\",\n  tidy = FALSE,\n  error = FALSE,\n  fig.width = 8,\n  fig.height = 8)\n```\n\n# cyclocomp\n\n\u003e Cyclomatic Complexity of R Code\n\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n[![Linux Build Status](https://travis-ci.org/MangoTheCat/cyclocomp.svg?branch=master)](https://travis-ci.org/MangoTheCat/cyclocomp)\n[![Windows Build status](https://ci.appveyor.com/api/projects/status/github/MangoTheCat/cyclocomp?svg=true)](https://ci.appveyor.com/project/gaborcsardi/cyclocomp)\n[![](http://www.r-pkg.org/badges/version/cyclocomp)](http://www.r-pkg.org/pkg/cyclocomp)\n[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/cyclocomp)](http://www.r-pkg.org/pkg/cyclocomp)\n[![Coverage Status](https://img.shields.io/codecov/c/github/MangoTheCat/cyclocomp/master.svg)](https://codecov.io/github/MangoTheCat/cyclocomp?branch=master)\n\nCyclomatic complexity is a software metric (measurement), used to indicate\n  the complexity of a program. It is a quantitative measure of the number of\n  linearly independent paths through a program's source code. It was developed\n  by Thomas J. McCabe, Sr. in 1976.\n\n## Installation\n\n```{r eval = FALSE}\ndevtools::install_github(\"MangoTheCat/cyclocomp\")\n```\n\n## Usage\n\n```{r}\nlibrary(cyclocomp)\n```\n\n`cyclocomp` takes quoted R expressions or function objects,\nand returns a single integer, the cyclomatic complexity of the\nexpression or function.\n\n```{r}\ncyclocomp(quote( if (condition) \"foo\" else \"bar\" ))\ncyclocomp(quote( while (condition) { loop } ))\n```\n\n```{r}\ncyclocomp(\n  function(arg) { calulate(this); and(that) }\n)\ncyclocomp(ls)\ncyclocomp(cyclocomp)\n```\n\nSome more examples for the R control structures. A simple `if`\nfirst:\n\n```{r}\ncyclocomp(quote({\n  if (condition) this\n}))\n```\n\nAn `if` with an `else` branch:\n\n```{r}\ncyclocomp(quote({\n  if (condition) this else that\n}))\n  ```\n\nLoops:\n\n```{r}\ncyclocomp(quote({\n  for (var in seq) expr\n}))\n```\n\n```{r}\ncyclocomp(quote({\n  while (cond) expr\n}))\n```\n\n```{r}\ncyclocomp(quote({\n  repeat expr\n}))\n```\n\n`break` and `next` statements add to the complexity:\n\n```{r}\ncyclocomp(quote({\n  for (var in seq) {\n    this\n    break\n    that\n  }\n}))\n```\n\n```{r}\ncyclocomp(quote({\n  for (var in seq) {\n    this\n    next\n    that\n  }\n}))\n```\n\nMultiple (explicit or implicit) `return` calls also add to the\ncomplexity:\n\n```{r}\nf \u003c- function(arg) {\n  if (arg) {\n    return(\"this\")\n  } else {\n    return(\"that\")\n  }\n  \"Otherwise return me\"\n}\ncyclocomp(f)\n```\n\n\n## License\n\nMIT © Mango Solutions\n","funding_links":[],"categories":["Programming Languages","R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMangoTheCat%2Fcyclocomp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMangoTheCat%2Fcyclocomp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMangoTheCat%2Fcyclocomp/lists"}