Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatters/ruby:chore - removing unnecessary error messages #1024

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/controllers/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,12 @@ func (a *Analyzer) removeWarningsFromErrors() {
}

// isWarning workaround to check if the message it's form a warning until the formatters are refactored
// nolint:gocyclo // necessary complexity, but will be removed in the future
func (a *Analyzer) isWarning(err string) bool {
return strings.Contains(err, messages.MsgErrorPackageLockJSONNotFound) ||
strings.Contains(err, messages.MsgErrorYarnLockNotFound) ||
strings.Contains(err, messages.MsgErrorNotFoundRequirementsTxt) ||
strings.Contains(err, messages.MsgWarnPathIsInvalidGitRepository)
strings.Contains(err, messages.MsgWarnPathIsInvalidGitRepository) ||
strings.Contains(err, messages.MsgWarnBrakemanNotRubyOnRailsProject) ||
strings.Contains(err, messages.MsgWarnGemfileIsRequiredForBundler)
}
4 changes: 3 additions & 1 deletion internal/helpers/messages/warn.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ const (
// TODO: Remove MsgWarnAnalysisContainsOutdatedHash before release v2.10.0
MsgWarnAnalysisContainsOutdatedHash = "{HORUSEC_CLI} YOUR CONFIGURATION FILE CONTAINS SOME HASHES THAT WILL NO " +
"LONGER BE VALID AS OF v2.10.0 IS RELEASED. PLEASE UPDATE YOUR CONFIGURATION FILE WITH THE FOLLOWING HASHES:"
MsgWarnPathIsInvalidGitRepository = "{HORUSEC_CLI} The current path it's not a valid git repository"
MsgWarnPathIsInvalidGitRepository = "{HORUSEC_CLI} The current path it's not a valid git repository"
MsgWarnBrakemanNotRubyOnRailsProject = "brakeman only works on Ruby On Rails project"
MsgWarnGemfileIsRequiredForBundler = "Gemfile.lock file is required to execute Bundler analysis"
)
2 changes: 1 addition & 1 deletion internal/services/formatters/ruby/brakeman/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
notFoundError = "please supply the path to a rails application"
)

var ErrNotFoundRailsProject = errors.New("brakeman only works on Ruby On Rails project")
var ErrNotFoundRailsProject = errors.New(messages.MsgWarnBrakemanNotRubyOnRailsProject)

type Formatter struct {
formatters.IService
Expand Down
2 changes: 1 addition & 1 deletion internal/services/formatters/ruby/bundler/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
// nolint: stylecheck
// We actually want that this error message be capitalized since the file name that was
// not found is capitalized.
var ErrGemLockNotFound = errors.New("Gemfile.lock file is required to execute Bundler analysis")
var ErrGemLockNotFound = errors.New(messages.MsgWarnGemfileIsRequiredForBundler)

type Formatter struct {
formatters.IService
Expand Down