Crate rust_code_analysis

Source
Expand description

rust-code-analysis is a library to analyze and extract information from source codes written in many different programming languages.

You can find the source code of this software on GitHub, while issues and feature requests can be posted on the respective GitHub Issue Tracker.

§Supported Languages

  • C++
  • C#
  • CSS
  • Go
  • HTML
  • Java
  • JavaScript
  • The JavaScript used in Firefox internal
  • Python
  • Rust
  • Typescript

§Supported Metrics

  • CC: it calculates the code complexity examining the control flow of a program.
  • SLOC: it counts the number of lines in a source file.
  • PLOC: it counts the number of physical lines (instructions) contained in a source file.
  • LLOC: it counts the number of logical lines (statements) contained in a source file.
  • CLOC: it counts the number of comments in a source file.
  • BLANK: it counts the number of blank lines in a source file.
  • HALSTEAD: it is a suite that provides a series of information, such as the effort required to maintain the analyzed code, the size in bits to store the program, the difficulty to understand the code, an estimate of the number of bugs present in the codebase, and an estimate of the time needed to implement the software.
  • MI: it is a suite that allows to evaluate the maintainability of a software.
  • NOM: it counts the number of functions and closures in a file/trait/class.
  • NEXITS: it counts the number of possible exit points from a method/function.
  • NARGS: it counts the number of arguments of a function/method.

Modules§

abc
cognitive
cyclomatic
exit
halstead
loc
mi
nargs
nom
npa
npm
wmc

Structs§

AstCallback
AstCfg
Configuration options for retrieving the nodes of an AST.
AstNode
Information on an AST node.
AstPayload
The payload of an Ast request.
AstResponse
The response of an AST request.
CcommentCode
CodeMetrics
All metrics data.
CommentRm
CommentRmCfg
Configuration options for removing comments from a code.
ConcurrentRunner
A runner to process files concurrently.
Count
Count of different types of nodes in a code.
CountCfg
Configuration options for counting different types of nodes in a code.
CppCode
Dump
DumpCfg
Configuration options for dumping the AST of a code.
FilesData
Data related to files.
Filter
Find
FindCfg
Configuration options for finding different types of nodes in a code.
FuncSpace
Function space data.
Function
FunctionCfg
Configuration options for detecting the span of each function in a code.
FunctionSpan
Function span data.
JavaCode
JavascriptCode
Metrics
MetricsCfg
Configuration options for computing the metrics of a code.
MozjsCode
Node
An AST node.
Ops
All operands and operators of a space.
OpsCfg
Configuration options for retrieving all the operands and operators in a code.
OpsCode
Parser
PreprocCode
PreprocFile
Preprocessor data of a C/C++ file.
PreprocResults
Preprocessor data of a series of C/C++ files.
PythonCode
RustCode
TsxCode
TypescriptCode

Enums§

ConcurrentErrors
Series of errors that might happen when processing files concurrently.
LANG
The list of supported languages.
SpaceKind
The list of supported space kinds.

Traits§

Callback
A trait for callback functions.

Functions§

action
Runs a function, which implements the Callback trait, on a code written in one of the supported languages.
count
Counts the types of nodes specified in the input slice and the number of nodes in a code.
dump_node
Dumps the AST of a code.
dump_ops
Dumps all operands and operators of a code.
dump_root
Dumps the metrics of a code.
find
Finds the types of nodes specified in the input slice.
fix_includes
Constructs a dependency graph of the include directives in a C/C++ file.
function
Detects the span of each function in a code.
get_from_emacs_mode
Detects the language associated to the input Emacs mode.
get_from_ext
Detects the language associated to the input file extension.
get_function_spaces
Returns all function spaces data of a code.
get_language_for_file
Detects the language of a code using the extension of a file.
get_macros
Returns the macros contained in a C/C++ file.
get_ops
Returns all operators and operands of each space in a code.
guess_language
Guesses the language of a code.
metrics
Returns all function spaces data of a code. This function needs a parser to be created a priori in order to work.
operands_and_operators
Retrieves all the operators and operands of a code.
preprocess
Extracts preprocessor data from a C/C++ file and inserts these data in a PreprocResults object.
read_file
Reads a file.
read_file_with_eol
Reads a file and adds an EOL at its end.
rm_comments
Removes comments from a code.
write_file
Writes data to a file.

Type Aliases§

CcommentParser
The Ccomment language parser.
CppParser
The Cpp language parser.
JavaParser
The Java language parser.
JavascriptParser
The Javascript language parser.
MozjsParser
The Mozjs language parser.
PreprocParser
The Preproc language parser.
PythonParser
The Python language parser.
RustParser
The Rust language parser.
Span
Start and end positions of a node in a code in terms of rows and columns.
TsxParser
The Tsx language parser.
TypescriptParser
The Typescript language parser.