Questions tagged [cloc]

cloc (Count Lines of Code) counts lines of code, blank lines, and comment lines in source code in many different programming languages.

cloc (Count Lines of Code) is an open source Perl program that counts lines of code, blank lines, and comment lines in source code in many different programming languages. It can also determine differences in lines of code, blank lines, and comment lines between two files or even between two directory trees.

cloc runs on a variety of operating systems, including Linux, FreeBSD, Windows and OSX.

Documentation: https://github.com/AlDanial/cloc

Cloc is available for installation through homebrew on macs: brew install cloc

50 questions
52
votes
4 answers

CLOC ignore/exclude list file (.clocignore)

(Edit: see Proper Usage section on the bottom.) Main Question How do you get cloc to use its --exclude-list-file= option? Essentially, I'm trying to feed it a .clocignore file. Expected Behavior cloc documentation says the…
Venning
  • 744
  • 1
  • 5
  • 12
20
votes
1 answer

Combine `cloc` with `git blame`

cloc enables one to count the number of lines of code stored in a directory per language per type (blank, comment, or code). git blame enables one to see which part of a file belong to whom. I'm looking for a way to combine both so that one gets a…
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
9
votes
1 answer

How to ignore files based on suffix in cloc..?

It should be a trivial task but neither reading through the docs and man page nor googling brought up a solution to what I'm trying to achieve: cloc is scanning our source tree and we want it to ignore all *.html and *.css files. Is there some way…
ATV
  • 4,116
  • 3
  • 23
  • 42
2
votes
2 answers

Counting lines of code per author in a git repository

So I'm in a team with a few other programmers and need to get a lines-of-code count per author in our git repository. That doesn't just mean lines modified by author, because that would include blank and comment lines. Ideally, I would be able to…
2
votes
0 answers

Scala Source Code metrics : Cyclomatic or McCabe complexity, Halstead Complexity, Data Abstraction Coupling

I am looking for a command line tool which calculates the source code metrics for scala language. I have seen some tools which generated metrics on the basis of loc(lines of code)& comments and I don't need this metrics(cloc,sbt-stats). I want a…
shiva
  • 730
  • 8
  • 25
2
votes
1 answer

using cloc to count lines of codes in sub folders

My Operating System is Windows. I have a main folder that contains projects within each sub folders. I want to report on each folder with foldername.txt. Then later I can sum them up with --sum-reports option. I looked at their options can't find a…
Meidi
  • 562
  • 1
  • 8
  • 28
2
votes
3 answers

Using cloc (count Lines of Codes) result

I am writing a script for my research, and I want to get the total number of lines in a source file. I came around cloc and I think I am going to use it in my script. However, cloc gives result with too many information (unfortunately since I am a…
Arwa
  • 575
  • 1
  • 5
  • 17
1
vote
1 answer

How do I run cloc to check all python files of a directory including subdirectories but ignore any subdirectories that have the word migrations?

I installed cloc using brew. I like to check number of lines of code for a Django project. I definitely don't want to count those that inside migrations and only restrict to python files. I tried cloc --not-match-d=migrations --include-lang=python .…
Kim Stacks
  • 10,202
  • 35
  • 151
  • 282
1
vote
1 answer

How to add file extensions in CLOC(Count lines of code)

Am using cloc to count lines of code. There are 140 files are getting ignored as there BIN and esql files are there. How do I make cloc to read these files? How to read files with extensions like bin and esql?enter image description here
1
vote
1 answer

CLOC - how to count loc in a specific (unique) directory using match-d

I need to count lines of code in a specific directory named 'gen' and I cannot just hard code the path to this directory because it can be anywhere inside a root directory (the path is variable). Would be possible to use match-d? I don't want…
user10157300
1
vote
2 answers

CLOC diff (count line of code) with git header

im trying to check lines of code using diff in the git repository with last commit and HEAD, but there's an error showing up, $ cloc -- diff 182712379cae1b953c5976854e735134530e8241 HEAD Error: 0 text files. 0 text files. 0 files ignored. 2…
Sadzone
  • 73
  • 2
  • 13
1
vote
1 answer

Cloc doesn't do a recursive search in Docker container

When I run cloc inside a docker container, it does not seem to recursively search through the given directories, compared to running it stand-alone. Dockerfile: FROM python:3.6.2-alpine3.6 VOLUME "/data" WORKDIR /data RUN apk --no-cache add…
Oromë
  • 199
  • 2
  • 16
1
vote
3 answers

How to skip specific files while calculating Lines of Code?

I have a user case where I need to calculate Lines of Code per BUC-ID. I have achieved the same using git log --shortstat --grep=BUC3565-EPIC16 |grep -E "fil(e|es) changed" | awk -v BUC=$i '{ inserted+=$4; deleted+=$6; delta+=$4-$6i }…
user3256114
  • 119
  • 1
  • 13
1
vote
2 answers

Cloc (Count Lines of Code) different Header

I create with cloc a csv file and used this file later in a Java Application. This app runs on a linux vm, but I develope on a windows PC. The Problem: Cloc generate 2 different Header Command: cloc . --csv --quiet --by-file --unix Testoutput via…
user8415608
1
vote
2 answers

--exclude-lang = "xml" is not working using cloc

I have used --exclude-lang = "xml" and --exclude-lang = "designer.cs" to exclude designer and xml files from count of lines changes in two different folders but it's not working.
1
2 3 4