Skip to content

Raw Text Parser

Category: Parser (takes in source code and outputs cc.json)

This parser analyzes code, regardless of the programming language, to generate the metrics described below.

  • any (only considers the raw text)
  • Indentation Level: The number of lines of code of a file, with a certain indentation level or higher.
  • Lines of Code: The total number of lines in a file, including blank lines.
ParameterDescription
FILE or FOLDERfile/project to parse
-bf, --base-file=<baseFile>base cc.json file with checksums to skip unchanged files during analysis
--bypass-gitignoredisable automatic .gitignore-based file exclusion (uses regex-based exclusion of common build folders)
-e, --exclude=<exclude>comma-separated list of regex patterns to exclude files/folders (applied in addition to .gitignore patterns)
-fe, --file-extensions=<fileExtensions>comma-separated list of file-extensions to parse only those files (default: any)
--commit=<ref>analyze the codebase at a specific git commit, tag, branch, or date expression (creates a temporary worktree). Cannot be combined with --local-changes. See Commit-Based Analysis
-h, --helpdisplays this help and exits
-ibf, --include-build-foldersinclude build folders (out, build, dist and target) and common resource folders (e.g. resources, node_modules or files/folders starting with ’.’)
--local-changesonly analyze files that differ from the remote tracking branch (uncommitted, staged, unstaged, untracked). See Local Changes
-m, --metrics=metricscomma-separated list of metrics to be computed (all available metrics are computed if not specified)
--max-indentation-level=<maxIndentLvl>maximum Indentation Level (default 10)
-nc, --not-compressedsave uncompressed output File
-o, --output-file=<outputFile>output File (or empty for stdout)
--tab-width=<tabWidth>tab width used (estimated if not provided)
--verboseverbose mode
--without-default-excludes(“DEPRECATION WARNING: this flag will soon be disabled and replaced by ‘—include-build-folders’”) include build, target, dist, resources and out folders as well as files/folders starting with ’.’
Usage: ccsh rawtextparser [-h] [--bypass-gitignore] [--commit=<ref>] [-ibf]
[--local-changes] [-nc] [--verbose]
[--without-default-excludes]
[-bf=<baseFile>]
[--max-indentation-level=<maxIndentLvl>]
[-o=<outputFile>] [--tab-width=<tabWidth>]
[-e=<specifiedExcludePatterns>]...
[-fe=<fileExtensionsToAnalyse>]... [-m=metrics]...
FILE or FOLDER...

The RawTextParser can analyze either a single file or a project folder; here are some sample commands:

ccsh rawtextparser foo/bar/project
ccsh rawtextparser foo.txt --max-indentation-level=6 tab-width=4 --metrics=IndentationLevel, LinesOfCode
ccsh rawtextparser foo -o out.cc.json --exclude=*.html --exclude=bar
ccsh rawtextparser foo -o out.cc.json --bypass-gitignore

If a project is piped into the RawTextParser, the results and the piped project are merged. The resulting project has the project name specified for the RawTextParser.