Documentation ¶
Index ¶
- Constants
- Variables
- func Append(slice []string, elems ...string) []string
- func CheckDockerHost()
- func CheckForUpdates(currentVersion string)
- func DisableColor()
- func DockerCleanup()
- func EmptyMessage()
- func ErrorMessage(message string, a ...interface{})
- func GetCmdOptions(opts *QodanaOptions) []string
- func GetLinter(path string) string
- func GetLinterSystemDir(project string, linter string) string
- func IsInteractive() bool
- func OpenDir(path string) error
- func PrepareHost(opts *QodanaOptions)
- func Primary(text string, a ...interface{}) string
- func PrimaryBold(text string, a ...interface{}) string
- func PullImage(ctx context.Context, client *client.Client, image string)
- func ReadSarif(sarifPath string, printProblems bool) int
- func RunLinter(ctx context.Context, options *QodanaOptions) int
- func ShowReport(path string, port int)
- func SuccessMessage(message string, a ...interface{})
- func WarningMessage(message string, a ...interface{})
- func WriteQodanaYaml(path string, linter string)
- type CustomDependency
- type DependencyIgnore
- type DependencyOverride
- type Exclude
- type Include
- type License
- type LicenseRule
- type Plugin
- type Profile
- type QodanaOptions
- type QodanaYaml
Constants ¶
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 )
const ( // QodanaSuccessExitCode is Qodana exit code when the analysis is successfully completed. QodanaSuccessExitCode = 0 // QodanaFailThresholdExitCode same as QodanaSuccessExitCode, but the threshold is set and exceeded. QodanaFailThresholdExitCode = 255 // OfficialDockerPrefix is the prefix of official Qodana Docker images. OfficialDockerPrefix = "jetbrains/qodana" )
Variables ¶
var ( NoLineWidth = 7 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. TableSep = MiscStyle.Sprint("─") TableSepUp = MiscStyle.Sprint("┬") TableSepMid = MiscStyle.Sprint("│") TableSepDown = MiscStyle.Sprint("┴") TableUp = strings.Repeat(TableSep, NoLineWidth) + TableSepUp TableDown = strings.Repeat(TableSep, NoLineWidth) + TableSepDown )
styles and different declarations intended to be used only inside this file
var ( Interrupted = false SkipCheckForUpdateEnv = "QODANA_CLI_SKIP_CHECK_FOR_UPDATE" )
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.
var Version = "dev"
Functions ¶
func CheckDockerHost ¶ added in v0.7.3
func CheckDockerHost()
CheckDockerHost checks if the host is ready to run Qodana Docker images.
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 EmptyMessage ¶ added in v0.6.2
func EmptyMessage()
EmptyMessage is a message that is used when there is no message to show.
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 GetLinterSystemDir ¶ added in v0.6.0
GetLinterSystemDir returns path to <userCacheDir>/JetBrains/<linter>/<project-id>/.
func IsInteractive ¶
func IsInteractive() bool
IsInteractive returns true if the current execution environment is interactive (useful for colors/animations toggle).
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 PrimaryBold ¶
PrimaryBold prints a message in the primary bold style.
func RunLinter ¶
func RunLinter(ctx context.Context, options *QodanaOptions) int
RunLinter runs the linter with the given options.
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 ¶
WriteQodanaYaml writes the qodana.yaml file to the given path.
Types ¶
type CustomDependency ¶ added in v1.0.0
type CustomDependency struct { // Name is the name of the dependency. Name string `yaml:"name"` // Version is the dependency version. Version string `yaml:"version"` // Url is the dependency URL. Url string `yaml:"url,omitempty"` // License is the license of the dependency. Licenses []License `yaml:"licenses"` }
type DependencyIgnore ¶ added in v1.0.0
type DependencyIgnore struct { // Name is the name of the dependency to ignore. Name string `yaml:"name"` }
DependencyIgnore is a dependency to ignore for license checks in Qodana
type DependencyOverride ¶ added in v1.0.0
type DependencyOverride struct { // Name is dependency name. Name string `yaml:"name"` // Version is the dependency version. Version string `yaml:"version"` // Url is the dependency URL. Url string `yaml:"url,omitempty"` // License is the license of the dependency. Licenses []License `yaml:"licenses"` }
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 LicenseRule ¶ added in v1.0.0
type LicenseRule struct { // Keys is the list of project license SPDX IDs. Keys []string `yaml:"keys"` // Allowed is the list of allowed dependency licenses for project licenses. Allowed []string `yaml:"allowed,omitempty"` // Prohibited is the list of prohibited dependency licenses for project licenses. Prohibited []string `yaml:"prohibited,omitempty"` }
LicenseRule is a license rule to apply for license compatibility checks in Qodana
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 string StubProfile string Baseline string BaselineIncludeAbsent bool SaveReport bool ShowReport bool Port int Property []string Script string FailThreshold string Changes bool SendReport bool AnalysisId string Env []string Volumes []string User string PrintProblems bool SkipPull bool ClearCache bool }
QodanaOptions is a struct that contains all the options to run a Qodana linter.
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. Excludes []Exclude `yaml:"exclude,omitempty"` // Include property to enable the wanted checks. Includes []Include `yaml:"include,omitempty"` // Properties property to override IDE properties. Properties map[string]string `yaml:"properties,omitempty"` // Bootstrap contains a command to run in the container before the analysis starts. Bootstrap string `yaml:"bootstrap,omitempty"` // LicenseRules contains a list of license rules to apply for license checks. LicenseRules []LicenseRule `yaml:"licenseRules,omitempty"` // DependencyIgnores contains a list of dependencies to ignore for license checks in Qodana. DependencyIgnores []DependencyIgnore `yaml:"dependencyIgnores,omitempty"` // DependencyOverrides contains a list of dependencies metadata to override for license checks in Qodana. DependencyOverrides []DependencyOverride `yaml:"dependencyOverrides,omitempty"` // CustomDependencies contains a list of custom dependencies to add to license checks in Qodana. CustomDependencies []CustomDependency `yaml:"customDependencies,omitempty"` // Plugins property containing plugins to install. Plugins []Plugin `yaml:"plugins,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 LoadQodanaYaml ¶ added in v1.0.0
func LoadQodanaYaml(project string) *QodanaYaml
LoadQodanaYaml gets Qodana YAML from the project.