{"id":26728337,"url":"https://github.com/gaborcsardi/cyclocomp","last_synced_at":"2025-04-14T09:12:39.912Z","repository":{"id":191582855,"uuid":"684952497","full_name":"gaborcsardi/cyclocomp","owner":"gaborcsardi","description":"Cyclomatic complexity of R functions and expressions","archived":false,"fork":false,"pushed_at":"2024-11-09T13:55:30.000Z","size":129,"stargazers_count":2,"open_issues_count":12,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-14T09:12:08.923Z","etag":null,"topics":["code-analysis","complexity-measure","r"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"MangoTheCat/cyclocomp","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaborcsardi.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","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-08-30T07:35:49.000Z","updated_at":"2025-02-17T13:51:38.000Z","dependencies_parsed_at":"2025-03-27T22:32:59.640Z","dependency_job_id":"b0194a41-2021-4919-9fbb-d5b3f8ab75bd","html_url":"https://github.com/gaborcsardi/cyclocomp","commit_stats":null,"previous_names":["gaborcsardi/cyclocomp"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborcsardi%2Fcyclocomp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborcsardi%2Fcyclocomp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborcsardi%2Fcyclocomp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborcsardi%2Fcyclocomp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaborcsardi","download_url":"https://codeload.github.com/gaborcsardi/cyclocomp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852181,"owners_count":21171842,"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":["code-analysis","complexity-measure","r"],"created_at":"2025-03-27T22:32:46.000Z","updated_at":"2025-04-14T09:12:39.872Z","avatar_url":"https://github.com/gaborcsardi.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput:\n  github_document:\nalways_allow_html: yes\n---\n\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\u003c!-- badges: start --\u003e\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![](https://www.r-pkg.org/badges/version/cyclocomp)](https://www.r-pkg.org/pkg/cyclocomp)\n[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/cyclocomp)](https://www.r-pkg.org/pkg/cyclocomp)\n[![Coverage Status](https://img.shields.io/codecov/c/github/Gaborcsardi/cyclocomp/main.svg)](https://app.codecov.io/github/Gaborcsardi/cyclocomp?branch=main)\n[![R-CMD-check](https://github.com/gaborcsardi/cyclocomp/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/gaborcsardi/cyclocomp/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\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(\"Gaborcsardi/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; Posit Software, PBC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaborcsardi%2Fcyclocomp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaborcsardi%2Fcyclocomp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaborcsardi%2Fcyclocomp/lists"}