aldanial / cloc Goto Github PK
View Code? Open in Web Editor NEWcloc counts blank lines, comment lines, and physical lines of source code in many programming languages.
License: GNU General Public License v2.0
cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.
License: GNU General Public License v2.0
Files for the Coq proof assistant are currently classified as Verilog as they both use a .v extension. Comments are all of the form (* foo bar *)
, which is one way to distinguish the files from Verilog. Also the words "Inductive, Fixpoint, Definition, Theorem, Lemma, Proof, Qed, forall" appear with high frequency in Coq source and (I'm guessing) not so much in Verilog. Some sample code can be found here or here.
It would be awesome if you get the chance to add support, otherwise I might investigate doing so myself. Thanks.
Hi,
I can't get a count of my tsx files (Typescript + JSX) with cloc.
Would it be possible to add this feature?
I'm evaluating this for use in our CI Build/Metrics workflow. I ran it against a .Net Solution that has one .htm file (attached). CLOC returned:
files language blank comment code
1 HTML 4 0 57
The file is mostly JavaScript and mostly commented out. It appears to be counting the commented Javascript as code.
Option allowing Markdown output should be provided.
For instance: --md
For example, when running on https://github.com/coq/coq
I am facing https://sourceforge.net/p/cloc/bugs/101/ under Windows 7 SP1, 64bit with the bundled EXE version 1.62 and also 1.66 on NTFS filesystem.
Windows has a limit on the length of filenames. Perls Find::Find inherently has to deal with the limitation and therefor also cloc.
I am running cloc on a huge codebase, unfortunately, i cant create a minimal example presenting the problem or disclose the project structure. Running cloc on just the directory structure which poses the problem works fine, so i assume it has something todo when recursing through lots of folders.
Cloc is invoked with
--by-file --ignored ignored.log --found found.log --xml --out src.xml <relative path>
The error i get is:
Can't cd to ../../../.. from <relative path with length of 222>
: No such file or directory at C:/StrawberryPerl/perl/lib/File/Find.pm line 469.
Note, i am running the .pl against Strawberry Perl 5.22.1.2-32bit instead of the .exe for debugging reasons .
The relative path is prepended by a path of length 35, resulting in a total length of 256 for the directory. The error results in not output file, therefor missing results.
One temporary fix is to subst
the first part of the path to a new drive letter and hence save 33 chars.
I just wanted to test "CLOC" so I typed these two lines in bash, but it didn't work.
xapple@local ~ $ brew install cloc
==> Downloading https://homebrew.bintray.com/bottles/cloc-1.66.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cloc-1.66.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/cloc/1.66: 5 files, 526K
xapple@local ~ $
xapple@local ~ $
xapple@local ~ $ cloc /repos/cool_project/
Can't locate Algorithm/Diff.pm in @INC (@INC contains: /Users/xapple/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level /Users/xapple/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0 /Users/xapple/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0/darwin-2level /Users/xapple/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0 .) at /usr/local/bin/cloc line 71.
BEGIN failed--compilation aborted at /usr/local/bin/cloc line 71.
xapple@local ~ $
I use this tool as part of my build process within a Jenkins server. I run 4 build variations every night when there are code changes.. Over the last 10 times the 4 variations have run, there have been 2 failures (out of 40 executions of cloc). On the most recent instance, the 1st of the 4 variations failed and the remaining 3 were successful.
EDIT: The "assertion failed" always happens on the Jenkins server but never happens when we run on the command line directly but does not cause the build to fail. Added additional line showing the Unknown exception that the build fails on. Don't know if the error is at the end of the first command line or the beginning of the second command line.
I get the following error message when this occurs.
23:51:26 assertion failed: open my_perl
23:51:26 assertion failed: MZ magic bytes
23:51:26 assertion failed: PE header
23:51:26 assertion failed: IMAGE_NT_OPTIONAL_HDR_MAGIC
23:51:26 amk E457: ["makefile" 158/0] uncaught 'Unknown' exception (ffffffff) while executing 'PR11940_GEN7_2_PostBuild'
We run the command twice to get both the detailed and summary data:
cloc-1.62 --by-file --progress-rate=0 --quiet --report-file=PR11940_cloc_report.xml --list-file=PR11940_cloc.txt
cloc-1.62 --progress-rate=0 --quiet --report-file=PR11940_GEN7_2_cloc_report.txt --list-file=PR11940_GEN7_2_cloc.txt
In the process of upgrading to v1.64 to see if problem repeats but also would like to be able to capture some additional debug information if that would be helpful to finding the root cause of the issue
Hello, how I exclude sub dir, example: src/test, src/docs. Thanks
Maybe I am missing something, but I can't get the by-percent option to work at all, I just get the same message every time, "Unknown option: by_percent".
Could jade files be added please? They are template files mainly used with Node.js. http://jade-lang.com/ has a sample on the left, and more infomation on the lanaguage.
Files with .kts
extension should be processed as Kotlin files.
More information at: https://kotlinlang.org/docs/tutorials/command-line.html
Would it be possible to add support for the Logtalk programming language? Logtalk extends Prolog and thus uses the same line comment and block comment syntax. Logtalk source files extensions are .lgt
and .logtalk
. For some sample code see e.g.
https://github.com/LogtalkDotOrg/logtalk3/blob/master/core/logtalk.lgt
https://github.com/LogtalkDotOrg/logtalk3/blob/master/core/expanding.lgt
Thanks for developing cloc
.
When block comments and line comment are used in a single line, cloc
gets confused and miscounts comments and LS for the processed file. Observed with C/C++ files.
Example:
/* data 1 */ // KO, processed as LS
int i;
/* data 2 */ /* OK, processed as comment */
int j;
Result:
Language files blank comment code
-------------------------------------------------------------------------------
C 1 1 1 3
Expected:
C 1 1 2 2
Hi! I've run into an issue where cloc is reporting incorrect lines counts in certain cases involving block comment delimiters inside a string in PHP code. I've attached a test script that demonstrates the issue. I have not yet tried it with any other languages.
The test file contains three functions. The first has a /*
inside a string literal and the third has a block comment above it. (In this example, the block comment is a PHPDoc docblock, but the issue happens with a plain block comment too). The correct counts for this file are 4 comment lines and 16 code lines. However, the actual output from cloc is 11 comment and 9 code.
Base on my testing, it looks like cloc is incorrectly flagging the /*
and */
as valid comment delimiters in the following cases:
#
or //
in PHP) on a line that starts with some code. Note that the delimiters are correctly ignored if they occur in a line comment that doesn't have any code before it, i.e. the line is just whitespace and comment.Note that if no closing */
is found in a string literal, a real block comment, or a comment as described above, the initial /*
is correctly ignored. (Actually, the only reason I even noticed this is because I ran cloc on a file that had a /*
in a string literal at line 60 and didn't have a single */
until about 500 lines later.)
Hi,
I'd like to add support for Puppet's configuration language. Currently, CLOC treats it as PASCAL, and the LOC is very incorrect (I tested using the sample code below which has 19 LOC).
cloc sample.pp
...
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Pascal 1 3 15 6
-------------------------------------------------------------------------------
Could you point me how to write the plugin? Thanks!
1. File extensions associated with the language.
.pp
2. A description of how comments are defined
It supports two styles of comments:
https://docs.puppetlabs.com/puppet/latest/reference/lang_comments.html
(1) Shell-stype (begin with #
)
# This is a comment
(2) C-style (delimited by slashes with inner asterisks.)
/*
this is a comment
*/
3. Sample code
#sample.pp
case $operatingsystem {
centos, redhat: { $service_name = 'ntpd' }
debian, ubuntu: { $service_name = 'ntp' }
}
package { 'ntp':
ensure => installed,
}
service { 'ntp':
name => $service_name,
ensure => running,
enable => true,
subscribe => File['ntp.conf'],
}
file { 'ntp.conf':
path => '/etc/ntp.conf',
ensure => file,
require => Package['ntp'],
source => "puppet:///modules/ntp/ntp.conf",
# This source file would be located on the Puppet master at
# /etc/puppetlabs/code/modules/ntp/files/ntp.conf
}
Here is a brief intro of the language:
https://docs.puppetlabs.com/puppet/4.2/reference/lang_summary.html
Diff error (quoted comments?) happens when I execute cloc --diff for diff-fail.c below.
{/* begin */
{
}
}/* end */
perl modcloc-1.64.pl --v=1 --skip-uniqueness --diff diff-fail.c diff-fail.c >& diff-fail.log
where modcloc-1.64.pl is only for additional loggings:
diff cloc-1.64.pl modcloc-1.64.pl
8951a8952,8955
>
> print " ## $flag L=$n_L: [$line_L]\n";
> print " ## $flag R=$n_R: [$line_R]\n";
>
9033a9038
> die "diff failed !\n";
This error may happen when the source file has a "code" + "comment" line followed by a "code" line, where these two "code" parts are exactly same.
It would be nice if cloc could be automatically launched from Grunt with relevant options.
Note. if you think I'm using Grunt, you're right ;)
Grunt plugins are available for Sloc, Sloccount and file-sloc.
--read-lang-def seems to be doing nothing
Happens under MacOSX both on brew-installed 1.64 and downloaded 1.66 release from this repo.
> cloc --write-lang-def=def.txt
> cloc --read-lang-def=def.txt
Usage: cloc [options] <file(s)/dir(s)> | <set 1> <set 2> | <report files>
[the rest of help here]
> echo $?
255
XMI files should be processed as XML files unless they get supported specifically (.xmi extension).
json is my favourite serialization format and I need to handle the output programatically - from python
Hey! Thanks for cloc
, it's awesome!
I maintain the cloc
package in Fedora and just got notified that Cloc bundles a version of Regexp::Common
that both Fedora and GNU consider non-free. Newer versions of Regexp::Common use other licenses in addition, which are considered free.
Would it be possible to either bump the bundled Regexp::Common
to something with a free license or (perhaps preferably) stop bundling it and just depend on it and use its API? Would this break anything? (I'm not sure what the original reason for bundling was.)
Hi, thanks for this wonderful tool.
It would be great to have support for Elm, the syntax of Elm is very heavily inspired by Haskell so hopefully we can reuse the Haskell code.
http://elm-lang.org/
Comments are exactly the same as they are in Haskell, here's the reference for comments in elm:
http://elm-lang.org/docs/syntax#comments
All Elm files end in '.elm'
Some sample code can be found here:
http://elm-lang.org/examples
for a non trivial sized sample see:
http://elm-lang.org/examples/pong
Please let me know anything else you might need, and anything I can do to help
Many Unicode characters are arrows.
Maybe one of them could be used for the readme.md
file allowing to get rid of the up.gif
file.
For example, the following line:
# [Basic Use![^](up.gif)](#___top "click to go to top of document")
would be replaced with:
# [Basic Use ▲](#___top "click to go to top of document")
and rendered:
Modern browsers handle Unicode charsets (UTF-8...) with no difficulty.
A nice table provides arrows available at http://unicode-table.com/en/sets/arrows-symbols/ .
I just stop by to say thank you for this nice utility!
You can see my favorite use-case here: https://jorin.me/git-cloc/
Keep up the good work!
(Feel free to close the issue. Just couldn't see another way to contact you.)
I have a directory full of ".smarty" files and PHP files.
Calling cloc on this directory do not report smarty file, only php files. Only lines of code , comments ect of the PHP files are reported. Smarty files are ignored.
To reproduce :
{if $cta.style eq 'STYLE_DROPDOWNLIST'}
<div class="list{if isset($cta.dimension)} grid-col span_{$cta.dimension}_of_12{/if}">
</div>
{elseif $cta.style eq 'STYLE_SIMPLELINK'}
<h1>HELLO WORLD</h1>
{else}
<h1>HELLO WORLD 2</h1>
{/if}
Although I suppose everyone has monitors for 200+ characters per line today, I am certain that I am not the only one using small windows for quick tasks. These windows usually have the very sensible width of 80 columns, as you seem to know very well by the code.
However, see
[mg@localhost cloc]$ ./cloc .
14 text files.
9 unique files.
11 files ignored.
https://github.com/AlDanial/cloc v 1.66 T=0.16 s (24.4 files/s, 124011.8 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
I know you want credit, but do you need the whole URL? It will wrap very often.
I would change it to AlDanial/cloc (5 top results in google for this string is you anyway).
If you really need a URL, consider using a shortener.
Thanks, and note that I am just trying to improve everyone's experience when using your software.
> ./cloc-1.64.exe --write-lang-def=my_cloc_language_definitions.txt
> ./cloc-1.64.exe --read-lang-def=my_cloc_language_definitions.txt .
Missing computer language name, line 1 of my_cloc_language_definitions.txt
Removing this first section in the file helps:
(unknown)
3rd_gen_scale 0.00
Hello.
Thanks for the great tools.
Please add support for PHP templating files "Twig"
Language name : Twig
File extensions associated with the language =.twig
Comments are like HTML, {# comment #}
Samples : http://twig.sensiolabs.org/doc/templates.html
Syntax is very similar to Ruby.
#! /usr/bin/env crystal
#
(like Ruby).cr
(instead of .rb
in Ruby)Rakefile
/Gemfile
/etc (unlike Ruby).Example code of a lib I just wrote: https://github.com/meskyanichi/commander
Nemerle language (http://nemerle.org/About) defines comment blocks like many languages already supported (C++, C# or Scala...). Therefore, that language may be supported easily by processing source files with .n extension.
I'm not sure if this was ever filed, but it'd be nice to have .gitignore respected. is that possible?
This is the scripting language for the Godot game engine.
The file extension is .gd and the comments are everything following a # to the end of the line, like in python and most other scripting languages.
Here's a sample file https://github.com/godotengine/godot/blob/master/demos/2d/area_input/input.gd
The homebrew recipe still points to the sourceforge site. It probably also should refer to a more modern version instead of 1.64.
system envirenment:LINUX
CLOC version:1.56
CPU core: 8
QUESTION:
when i use the cloc.pl tool to get difference between tows source codes,
cloc tool just use one cpu core to run .
As follows:
since inefficiency of using one cpu core,cloc tool takes me too much time to wait the result.
what should i do to increase the efficiency of cloc tool.
There is actually the Version 1.60, can you update this please?
Many of us use XHTML outside of JavaServer faces ;-).
Right now, we're forced to use the additional flag:
--force-lang="HTML",xhtml
And then it counts them as "HTML" files, which isn't accurate.
Please add support for TTCN (a general testing language)
Patch with a suggestion for implementation: cloc-1.66.e1.patch.txt
See following bug report:
https://bugs.archlinux.org/task/45494
and kentcdodds/cloc#1
which happens when you install cloc with npm.
If possible, project data should be updated at: https://www.openhub.net/p/cloc
According to http://sourceforge.net/p/cloc/feature-requests/69/ the language R should be analyzed since 1.62. When applying cloc 1.64 (or 1.62) on https://github.com/Dennis1989/MOCK I it only finds C++, XML, and Headers.
We have some Qt translation files (*.ts / like *.po(t) of gettext) in our repository and cloc detect this as "TypeScript" because of the file ending.
http://doc.qt.io/qt-5/linguist-ts-file-format.html
Example file:
http://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/tools/i18n/translations/i18n_de.ts
`
`There are no extensions. There are two special named files: Jamfile
and Jamrules
.
Comments are single line only. They start with #
and end on the end of the line.
copied from https://sourceforge.net/p/cloc/bugs/138/
When creating summary report with --sum-reports
option the hypens are to short:
-------------------------------------------------------------------------------------
File files blank comment code
-------------------------------------------------------------------------------------
directory/test1234 696 13535 23433 86058
directory/test123 458 11511 11403 66143
directory/test123456789 343 4167 7979 37972
directory_1/test_123445678901234 13 81 264 497
directory_1/test_12344567890123456 4 38 176 179
-------------------------------------------------------------------------------------
SUM: 2208 41016 61090 256197
-------------------------------------------------------------------------------------
File extensions: 4th, f, for, forth, fr, frt, fth, fs. These are supported by GitHub's Linguist.
Comments:
\
to end of line.(
to )
on same line.(*
starts a multi-line comment ending with *)
.Note that the token starting the comment must be surrounded by whitespace.
Links to sample code:
http://github.com/larsbrinkhoff/lbForth/blob/master/kernel.fth
http://github.com/search?q=language%3Aforth+dup+swap&type=Code
Hi there,
I'm trying to --not-match-d
a dir/subdir
(which I do with --not-match-d="(dir\/subdir)"
but it doesn't seem to work. Also there are cases where I'd like to match a directory and file name together like dir/file.*
and for which I need to resort to --exclude-list-file
.
I wonder whether you could implement a --match
and --not-match
which would match on the complete relative (or absolute) path (directory + basename)?
Thanks for the great tool!
Jun
Hi,
How I can mark docstrings as comment to counting line of code?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.