core

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QDJVMC = "jetbrains/qodana-jvm-community:" + version
	QDJVM  = "jetbrains/qodana-jvm:" + version + eap
	QDAND  = "jetbrains/qodana-jvm-android:" + version + eap
	QDPHP  = "jetbrains/qodana-php:" + version + eap
	QDPY   = "jetbrains/qodana-python:" + version + eap
	QDJS   = "jetbrains/qodana-js:" + version + eap
)
View Source
const (
	QodanaSuccessExitCode       = 0
	QodanaFailThresholdExitCode = 255
	OfficialDockerPrefix        = "jetbrains/qodana"
)

Variables

View Source
var (
	Version     = "0.7.2"
	DoNotTrack  = false
	Interrupted = false
)
View Source
var (
	SpinnerSequence  = []string{"| ", "/ ", "- ", "\\ "}
	QodanaSpinner    = pterm.DefaultSpinner
	PrimaryStyle     = pterm.NewStyle()               // PrimaryStyle is a primary text style.
	PrimaryBoldStyle = pterm.NewStyle(pterm.Bold)     // PrimaryBoldStyle is a primary bold text style.
	ErrorStyle       = pterm.NewStyle(pterm.FgRed)    // ErrorStyle is an error style.
	WarningStyle     = pterm.NewStyle(pterm.FgYellow) // WarningStyle is a warning style.
	MiscStyle        = pterm.NewStyle(pterm.FgGray)   // MiscStyle is a log style.
)

styles and different declarations intended to be used only inside this file

View Source
var Info = fmt.Sprintf(`
  %s (v%s)
  https://jb.gg/qodana-cli
  Documentation – https://jb.gg/qodana-docs
  Contact us at qodana-support@jetbrains.com
  Bug Tracker: https://jb.gg/qodana-issue
  Community forum: https://jb.gg/qodana-forum
`, "Qodana CLI", Version)

Info Two newlines at the start are important to lay the output nicely in CLI.

View Source
var (
	UnofficialLinter = false
)

Functions

func Append added in v0.7.0

func Append(slice []string, elems ...string) []string

Append appends a string to a slice if it's not already there.

func CheckForUpdates added in v0.6.3

func CheckForUpdates(currentVersion string)

CheckForUpdates check GitHub https://github.com/JetBrains/qodana-cli/ for the latest version of CLI release.

func CheckLinter

func CheckLinter(image string)

CheckLinter validates the image used for the scan.

func ConfigureProject

func ConfigureProject(projectDir string) []string

ConfigureProject sets up the project directory for Qodana CLI to run Looks up .idea directory to determine used modules If a project doesn't have .idea, then runs language detector

func Contains

func Contains(s []string, str string) bool

Contains checks if a string is in a given slice.

func DisableColor added in v0.6.2

func DisableColor()

DisableColor disables colors in the output.

func DockerCleanup

func DockerCleanup()

DockerCleanup cleans up Qodana containers

func EmptyMessage added in v0.6.2

func EmptyMessage()

EmptyMessage is a message that is used when there is no message to show.

func EnsureDockerInstalled added in v0.7.1

func EnsureDockerInstalled()

EnsureDockerInstalled checks if docker is installed.

func EnsureDockerRunning

func EnsureDockerRunning()

EnsureDockerRunning checks if docker daemon is running.

func ErrorMessage

func ErrorMessage(message string, a ...interface{})

ErrorMessage prints an error message with the icon.

func GetCmdOptions added in v0.7.1

func GetCmdOptions(opts *QodanaOptions) []string

GetCmdOptions returns qodana command options.

func GetLinter added in v0.6.2

func GetLinter(path string) string

func GetLinterSystemDir added in v0.6.0

func GetLinterSystemDir(project string, linter string) string

GetLinterSystemDir returns path to <userCacheDir>/JetBrains/<linter>/<project-hash>/

func IsDockerInstalled added in v0.7.1

func IsDockerInstalled() error

func IsInteractive

func IsInteractive() bool

IsInteractive returns true if the current execution environment is interactive (useful for colors/animations toggle).

func OpenDir added in v0.6.2

func OpenDir(path string) error

OpenDir opens directory in the default file manager

func PrepareHost added in v0.6.5

func PrepareHost(opts *QodanaOptions)

PrepareHost cleans up report folder, gets the current user, creates the necessary folders for the analysis

func Primary

func Primary(text string, a ...interface{}) string

func PrimaryBold

func PrimaryBold(text string, a ...interface{}) string

func PrintProcess

func PrintProcess(f func(), start string, finished string)

PrintProcess prints the message for processing phase. TODO: Add ETA based on previous runs

func PullImage added in v0.7.1

func PullImage(ctx context.Context, client *client.Client, image string)

PullImage pulls docker image

func ReadSarif

func ReadSarif(resultsDir string, printProblems bool)

ReadSarif prints Qodana Scan result into stdout

func RunLinter

func RunLinter(ctx context.Context, options *QodanaOptions) int

RunLinter runs the linter with the given options.

func ShowReport

func ShowReport(path string, port int)

ShowReport serves the Qodana report

func SuccessMessage

func SuccessMessage(message string, a ...interface{})

SuccessMessage prints a success message with the icon.

func WarningMessage

func WarningMessage(message string, a ...interface{})

WarningMessage prints a warning message with the icon.

func WriteQodanaYaml

func WriteQodanaYaml(path string, linters []string)

WriteQodanaYaml writes the qodana.yaml file to the given path.

Types

type Exclude

type Exclude struct {
	// The name of check to exclude.
	Name string `yaml:"name"`

	// Relative to the project root path to disable analysis.
	Paths []string `yaml:"paths,omitempty"`
}

Exclude A check id to disable.

type Include

type Include struct {
	// The name of check to exclude.
	Name string `yaml:"name"`
}

Include A check id to enable.

type Plugin added in v0.6.3

type Plugin struct {
	// Id plugin id to install
	Id string `yaml:"id"`

	// Version plugin version to install
	Version string `yaml:"plugins,omitempty"`
}

Plugin to be installed during the Qodana run.

type Profile

type Profile struct {
	// Name profile name to use.
	Name string `yaml:"name,omitempty"`

	// Path profile path to use.
	Path string `yaml:"path,omitempty"`
}

Profile A profile is some template set of checks to run with Qodana analysis.

type QodanaOptions

type QodanaOptions struct {
	ResultsDir            string
	CacheDir              string
	ProjectDir            string
	Linter                string
	SourceDirectory       string
	DisableSanity         bool
	ProfileName           string
	ProfilePath           string
	RunPromo              bool
	StubProfile           string
	Baseline              string
	BaselineIncludeAbsent bool
	SaveReport            bool
	ShowReport            bool
	Port                  int
	Property              string
	Script                string
	FailThreshold         string
	Changes               bool
	SendReport            bool
	Token                 string
	AnalysisId            string
	Env                   []string
	Volumes               []string
	User                  string
	PrintProblems         bool
	SkipPull              bool
}

type QodanaYaml

type QodanaYaml struct {
	// The qodana.yaml version of this log file.
	Version string `yaml:"version,omitempty"`

	// Linter to run.
	Linter string `yaml:"linter"`

	// Profile is the profile configuration for Qodana analysis.
	Profile Profile `yaml:"profile,omitempty"`

	// FailThreshold is a number of problems to fail the analysis (to exit from Qodana with code 255).
	FailThreshold int `yaml:"failThreshold,omitempty"`

	// Exclude property to disable the wanted checks on the wanted paths.
	Exclude []Exclude `yaml:"exclude,omitempty"`

	// Include property to enable the wanted checks.
	Include []Include `yaml:"include,omitempty"`

	// Properties property to override IDE properties
	Properties map[string]string `yaml:"properties,omitempty"`

	// Plugins property containing plugins to install
	Plugins []Plugin `yaml:"plugins,omitempty"`

	// Bootstrap contains a command to run in the container before the analysis starts
	Bootstrap string `yaml:"bootstrap,omitempty"`
}

QodanaYaml A standard qodana.yaml (or qodana.yml) format for Qodana configuration. https://github.com/JetBrains/qodana-profiles/blob/master/schemas/qodana-yaml-1.0.json

func GetQodanaYaml

func GetQodanaYaml(project string) *QodanaYaml

GetQodanaYaml gets Qodana YAML from the project.

Jump to

Keyboard shortcuts

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