CodeScene Command Reference¶
cs delta¶
DESCRIPTION
Run a delta analysis. A delta analysis compares your current work against a
previous state of your code. See also `cs docs git-hooks`.
USAGE
$ cs delta [<options>] [<branch> [<branch>]]
OPTIONS
--staged Examine only staged content.
--interactive Run command with interactive mode, forcing user input for findings. For more info try `cs docs interactive`.
--git-hook Run as a git hook. For more info try `cs docs git-hooks`.
--output-format Output in json or edn format. Default is human-readable.
--pretty Use in conjunction with --format to pretty-print the output.
--verbose Verbose output
-h, --help Show this help
EXAMPLES
$ cs delta Analyse all non-committed changes
$ cs delta --file src/Server.js Analyse one file
$ cs delta --output-format json As above, but output in json format. Note that
specifying any output-format will report new issues
only - i.e. no improvents or explanations
$ cs delta main Analyse changes against the main branch
$ cs delta main feat Analyse changes between two branches
$ cs delta main~30 main Analyse the latest 30 commits on main
cs review¶
DESCRIPTION
Check a file for code health issues and print the results in a JSON structure
USAGE
$ cs review [<options>] [<file>]
OPTIONS
--file-name Specify the file-name when reading from stdin
--output-format Output in json or edn format. Default is human-readable.
--pretty Use in conjunction with --format to pretty-print the output.
--verbose Verbose output
-h, --help Show this help
EXAMPLES
$ cs review test.c Check the file test.c
$ cs review master:./test.c Check the file test.c on the master branch
$ cs review 801b0c0f:./test.c Check the file test.c at the given commit
$ cs review --file-name test.c < test.c Read file data from stdin
cs check¶
DESCRIPTION
Check a file for code health issues and print the results in a lint-like manner.
USAGE
$ cs check [<options>] [<file>]
OPTIONS
--file-name Specify the file-type/extension when reading from stdin
--verbose Verbose output
-h, --help Show this help
EXAMPLES
$ cs check test.c Check the file test.c
$ cs check master:./test.c Check the file test.c on the master branch
$ cs check 801b0c0f:./test.c Check the file test.c at the given commit
$ cs check --file-name test.c < test.c Read file data from stdin
DESCRIPTION
CodeScene CLI documentation topics
cs docs¶
USAGE
$ cs docs <topic>
example `cs docs git-hooks`
AVAILABLE TOPICS
Delta analysis
📄 git-hooks Using the delta command in a git hook
📄 interactive Using the delta command in interactive mode to prompt user input
📄 interactive-pre-commit-hook-example Outputs an example pre-commit hook using interactive
📄 pre-commit-hook-example Outputs an example pre-commit hook
Editor integration
📄 vim Integrating the "check" command in (neo)vim
Miscellaneous
📄 license Setting up a license
📄 file-name File-name and language support
📄 code-health-rules Customizing code health rules
📄 code-health-rules-template Outputs a code health rules template
cs check-rules¶
DESCRIPTION
Find out which of your custom rules, if any, matches the given file
This use useful when creating custom code-health-rules.json
USAGE
$ cs check-rules [<file>]
EXAMPLES
$ cs check-rules test.c Check which code health rule that matches test.c
cs rules-config¶
DESCRIPTION
Validate and edit a code-health-rules.json configuration file
Supports four subcommands: validate, set-rule, set-threshold, list-thresholds
USAGE
$ cs rules-config validate [--config-path <path>]
$ cs rules-config set-rule --rule-name <name> --enabled true|false [selector-options]
$ cs rules-config set-threshold --threshold-name <name> --value <positive-int> [selector-options]
$ cs rules-config list-thresholds --language <name> [--format json] [--config-path <path>]
SELECTOR OPTIONS
--matching-content-path <glob> Required when multiple rule sets exist
COMMON OPTIONS
--config-path <path> Defaults to .codescene/code-health-rules.json in current git repo
--language <name> Language name, e.g. Python, JavaScript, Java
--format json Output format (only json is supported)
EXAMPLES
$ cs rules-config validate
$ cs rules-config validate --config-path /tmp/code-health-rules.json
$ cs rules-config set-rule --rule-name "Complex Method" --enabled false
$ cs rules-config set-rule --matching-content-path "**/*.js" --rule-name "Complex Method" --enabled false
$ cs rules-config set-threshold --threshold-name function_lines_of_code_warning --value 120
$ cs rules-config set-threshold --threshold-name function_lines_of_code_warning --value 120 --matching-content-path "**/*.js"
$ cs rules-config list-thresholds --language Python --format json
$ cs rules-config list-thresholds --language Java --format json
$ cs rules-config list-thresholds --language C# --format json
- Default file:
If no file is provided, the command uses
.codescene/code-health-rules.jsonfrom the current git repository.- Rule updates:
With a single
rule_setin the file,set-rulecan update the rule directly.
cs rules-config set-rule --rule-name "Complex Method" --enabled false
When multiple ``rule_set`` entries exist, pass ``--matching-content-path`` to select which ruleset to edit.
cs rules-config set-rule --matching-content-path "**/*.js" --rule-name "Complex Method" --enabled false
- Threshold updates:
With a single
rule_setin the file,set-thresholdcan update the threshold directly.
cs rules-config set-threshold --threshold-name function_lines_of_code_warning --value 120
When multiple ``rule_set`` entries exist, pass ``--matching-content-path`` to select which ruleset to edit.
cs rules-config set-threshold --matching-content-path "**/*.js" --threshold-name function_lines_of_code_warning --value 120
- Notes:
--enabled truestores weight1.0and--enabled falsestores weight0.0in the config file.If no config file exists when running
set-ruleorset-threshold, a minimal file is created automatically at the default path before the change is applied.If multiple
rule_setentries exist and you do not pass--matching-content-path, the command fails and prints available selectors.Unknown rule or threshold names fail with suggestions.
If an update creates invalid config, the original file is restored.
Top-level help (cs)¶
ENVIRONMENT
CS_ONPREM_URL Base URL for CodeScene Enterprise.
CS_DISABLE_VERSION_CHECK Set to disable the automatic version update check on startup.
CS_CERTS Path to DER, PEM or PKCS12 files with additional trusted certs,
comma or semicolon separated.
CS_CERTS_PASSWORD Password for PKCS12 files if any.
cs version¶
DESCRIPTION
Displays the version