Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hrbrmstr/cloc

🔢 R package to the perl cloc script (which counts blank lines, comment lines, and physical lines of source code in source files/trees/archives)
https://github.com/hrbrmstr/cloc

cloc count-lines-of-code r rstats

Last synced: 2 months ago
JSON representation

🔢 R package to the perl cloc script (which counts blank lines, comment lines, and physical lines of source code in source files/trees/archives)

Awesome Lists containing this project

README

        

---
format: gfm
editor_options:
chunk_output_type: console
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```

```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```

```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```

## What's Inside The Tin

The following functions are implemented:

```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```

## Installation

```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```

## Usage

```{r lib-ex}
library(cloc)
library(tibble) # for printing

# current version
packageVersion("cloc")

```

Basic usage

```{r cloc-basic, message=FALSE, warning=FALSE, error=FALSE}
# by dir
cloc(system.file("extdata", package="cloc"))

# by file
cloc(system.file("extdata", "qrencoder.cpp", package="cloc"))

# from a url
cloc("https://rud.is/dl/cloc-1.74.tar.gz")
```

Custom CRAN package counter:

```{r cloc-cran, message=FALSE, warning=FALSE, error=FALSE}
cloc_cran(c("archdata", "hrbrthemes", "iptools", "dplyr"))
```

git tree

```{r cloc-git-tree, message=FALSE, warning=FALSE, error=FALSE, eval=FALSE}
cloc_git("~/packages/cloc")
## source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct
## 1 cloc Perl 1 0.1111111 10059 0.9867569158 787 0.910879630 1292 0.9570370370
## 2 cloc Markdown 2 0.2222222 60 0.0058858152 31 0.035879630 0 0.0000000000
## 3 cloc R 4 0.4444444 52 0.0051010398 22 0.025462963 25 0.0185185185
## 4 cloc Rmd 1 0.1111111 13 0.0012752600 21 0.024305556 32 0.0237037037
## 5 cloc YAML 1 0.1111111 10 0.0009809692 3 0.003472222 1 0.0007407407
```

git tree (with specific commit)

```{r cloc-git-tree-commit, message=FALSE, warning=FALSE, error=FALSE, eval=FALSE}
cloc_git("~/packages/cloc", "3643cd09d4b951b1b35d32dffe35985dfe7756c4")
## source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct
## 1 cloc Perl 1 0.1111111 10059 0.9867569158 787 0.910879630 1292 0.9570370370
## 2 cloc Markdown 2 0.2222222 60 0.0058858152 31 0.035879630 0 0.0000000000
## 3 cloc R 4 0.4444444 52 0.0051010398 22 0.025462963 25 0.0185185185
## 4 cloc Rmd 1 0.1111111 13 0.0012752600 21 0.024305556 32 0.0237037037
## 5 cloc YAML 1 0.1111111 10 0.0009809692 3 0.003472222 1 0.0007407407
```

remote git tree

```{r cloc-remote-git-tree, message=FALSE, warning=FALSE, error=FALSE}
cloc_git("https://github.com/maelle/convertagd.git")
```

Detailed results by file

```{r cloc-detailed, message=FALSE, warning=FALSE, error=FALSE}
# whole dir
str(cloc_by_file(system.file("extdata", package="cloc")))

# single file
str(cloc_by_file(system.file("extdata", "qrencoder.cpp", package="cloc")))
```

Recognized languages

```{r cloc-langs, message=FALSE, warning=FALSE, error=FALSE}
cloc_recognized_languages()
```

Strip comments and whitespace from individual source files

```{r cloc-strip, message=FALSE, warning=FALSE, error=FALSE}
cat(
cloc_remove_comments("https://raw.githubusercontent.com/maelle/convertagd/master/README.Rmd")
)
```

## cloc Metrics

```{r cloc-metrics, echo=FALSE}
cloc_pkg_md()
```

## Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.