Skip to content

Commit

Permalink
Added —no-clip flag to lint command
Browse files Browse the repository at this point in the history
No clipping on messages (if shown) or JSON paths.
  • Loading branch information
daveshanley committed Aug 5, 2024
1 parent 16479f3 commit e4a8a9d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func GetLintCommand() *cobra.Command {
allResults, _ := cmd.Flags().GetBool("all-results")
timeoutFlag, _ := cmd.Flags().GetInt("timeout")
hardModeFlag, _ := cmd.Flags().GetBool("hard-mode")
noClipFlag, _ := cmd.Flags().GetBool("no-clip")
ignoreArrayCircleRef, _ := cmd.Flags().GetBool("ignore-array-circle-ref")
ignorePolymorphCircleRef, _ := cmd.Flags().GetBool("ignore-polymorph-circle-ref")
ignoreFile, _ := cmd.Flags().GetString("ignore-file")
Expand Down Expand Up @@ -233,6 +234,7 @@ func GetLintCommand() *cobra.Command {
Lock: &printLock,
Logger: logger,
TimeoutFlag: timeoutFlag,
NoClip: noClipFlag,
IgnoreArrayCircleRef: ignoreArrayCircleRef,
IgnorePolymorphCircleRef: ignorePolymorphCircleRef,
IgnoredResults: ignoredItems,
Expand Down Expand Up @@ -284,6 +286,7 @@ func GetLintCommand() *cobra.Command {
cmd.Flags().Bool("ignore-array-circle-ref", false, "Ignore circular array references")
cmd.Flags().Bool("ignore-polymorph-circle-ref", false, "Ignore circular polymorphic references")
cmd.Flags().String("ignore-file", "", "Path to ignore file")
cmd.Flags().Bool("no-clip", false, "Do not truncate messages or paths (no '...')")
// TODO: Add globbed-files flag to other commands as well
cmd.Flags().String("globbed-files", "", "Glob pattern of files to lint")

Expand Down Expand Up @@ -376,6 +379,7 @@ func lintFile(req utils.LintFileRequest) (int64, int, error) {
req.Silent,
req.NoMessageFlag,
req.AllResultsFlag,
req.NoClip,
abs,
req.FileName)
}
Expand Down Expand Up @@ -428,6 +432,7 @@ func processResults(results []*model.RuleFunctionResult,
silent,
noMessage,
allResults bool,
noClip bool,
abs, filename string) {

if allResults && len(results) > 1000 {
Expand Down Expand Up @@ -485,15 +490,16 @@ func processResults(results []*model.RuleFunctionResult,
m := r.Message
p := r.Path

if len(r.Path) > 60 {
p = fmt.Sprintf("%s...", r.Path[:60])
}
if !noClip {
if len(r.Path) > 60 {
p = fmt.Sprintf("%s...", r.Path[:60])
}

if len(r.Message) > 100 {
m = fmt.Sprintf("%s...", r.Message[:80])
if len(r.Message) > 100 {
m = fmt.Sprintf("%s...", r.Message[:80])
}
}

sev := "nope"
sev := "info"
if r.Rule != nil {
sev = r.Rule.Severity
}
Expand Down

0 comments on commit e4a8a9d

Please sign in to comment.