lint

package
v0.14.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Command = &cobra.Command{
		Use:   "lint",
		Short: "lint examines TTCN-3 source files and reports suspicious code",
		Long: `lint examines TTCN-3 source files and reports suspicious code.
It may find problems not caught by the compiler, but also constructs
considered "bad style".

Lint's exit code is non-zero for erroneous invocation of the tool or if a
problem was reported.


Formatting Checks

    max_lines          Number of lines a behaviour body must not exceed.
    aligned_braces     Braces must be in the same column or same line.
    require_case_else  Every select-statement must have one case-else.


Cyclomatic Complexity Checks

    complexity.max           Cyclomatic complexity muss not exceed.
    complexity.ignore_guards Ignore complexity of alt- and interleave guards


Naming Convention Checks

    naming.modules            Checks for module identifiers.
    naming.tests              Checks for test-case identifier.
    naming.functions          Checks for function identifiers.
    naming.altsteps           Checks for altstep identifiers.
    naming.parameters         Checks for parameter identifiers.
    naming.component_vars     Checks for component variable identifiers.
    naming.var_templates      Checks for variable template identifiers.
    naming.port_types         Checks for port type identifiers.
    naming.ports              Checks for port instance identifiers.
    naming.global_consts      Checks for global constant identifiers.
    naming.component_consts   Checks for component scoped constant identifiers.
    naming.templates          Checks for constant template identifiers.
    naming.locals             Checks for local variable identifiers.

    tags.tests                Checks for test-case tags.


White-Listing

    ignore.modules    Ignore modules
    ignore.files      Ignore files


Refactoring

When TTCN-3 code is refactored incrementally, it happens that references to
legacy code are faster added than one can remove them. This check helps with a
warning, as soon as the usage of a symbol exceed a defined limit.


Unused Symbols

    unused.modules    Checks for unused modules


Example configuration file:

	aligned_braces: true
	require_case_else: true
	max_lines: 40

	usage:
	  "foo":
	    limit: 12
	    text: Use "bar" instead.

	unused:
	  modules: true

	complexity:
	  max: 15
	  ignore_guards: true

	tags:
	  tests:
	    "@author": "testcases must have a @author tag"

	naming:
	  tests:
	    # An exlamation mark inverts the match.
	    "!.{130,}": "testcase identifiers must not be longer than 130 characters"

	  functions:
	    "^[a-z]"      : "function identifiers must begin with a lower case letter"
	    "!^(f|func)_" : "function identifiers must not begin with f_ or func_"

	  global_consts:
	    "^[A-Z0-9_]+$": "global constants must be UPPER_CASE"

	ignore:
	  modules:
	    # Ignore generated modules
	    - "^Protobuf_.+$"

	  files:
	    # Ignore all files from generated folders
	    - "generated/"

For information on writing new checks, see <TBD>.
`,

		RunE: lint,
	}
)

Functions

This section is empty.

Types

type Import

type Import struct {
	Fset     *loc.FileSet
	Node     *ast.ImportDecl
	Path     string
	From     string
	Imported string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL