@@ -45,10 +45,10 @@ type ResultsSummary struct {
45
45
Types FailureTypes `json:"types"`
46
46
}
47
47
48
- //DetectionResults represents all interesting information collected during a detection run.
49
- //It serves as a collecting parameter for the tests performed by the various Detectors in the DetectorChain
50
- //Currently, it keeps track of failures and ignored files.
51
- //The results are grouped by FilePath for easy reporting of all detected problems with individual files.
48
+ // DetectionResults represents all interesting information collected during a detection run.
49
+ // It serves as a collecting parameter for the tests performed by the various Detectors in the DetectorChain
50
+ // Currently, it keeps track of failures and ignored files.
51
+ // The results are grouped by FilePath for easy reporting of all detected problems with individual files.
52
52
type DetectionResults struct {
53
53
mode talismanrc.Mode
54
54
Summary ResultsSummary `json:"summary"`
@@ -64,7 +64,7 @@ func (r *DetectionResults) getResultDetailsForFilePath(fileName gitrepo.FilePath
64
64
return nil
65
65
}
66
66
67
- //NewDetectionResults is a new DetectionResults struct. It represents the pre-run state of a Detection run.
67
+ // NewDetectionResults is a new DetectionResults struct. It represents the pre-run state of a Detection run.
68
68
func NewDetectionResults (mode talismanrc.Mode ) * DetectionResults {
69
69
return & DetectionResults {
70
70
mode ,
@@ -76,9 +76,9 @@ func NewDetectionResults(mode talismanrc.Mode) *DetectionResults {
76
76
77
77
}
78
78
79
- //Fail is used to mark the supplied FilePath as failing a detection for a supplied reason.
80
- //Detectors are encouraged to provide context sensitive messages so that fixing the errors is made simple for the end user
81
- //Fail may be called multiple times for each FilePath and the calls accumulate the provided reasons
79
+ // Fail is used to mark the supplied FilePath as failing a detection for a supplied reason.
80
+ // Detectors are encouraged to provide context sensitive messages so that fixing the errors is made simple for the end user
81
+ // Fail may be called multiple times for each FilePath and the calls accumulate the provided reasons
82
82
func (r * DetectionResults ) Fail (filePath gitrepo.FilePath , category string , message string , commits []string , severity severity.Severity ) {
83
83
isFilePresentInResults := false
84
84
for resultIndex := 0 ; resultIndex < len (r .Results ); resultIndex ++ {
@@ -131,8 +131,8 @@ func (r *DetectionResults) Warn(filePath gitrepo.FilePath, category string, mess
131
131
r .Summary .Types .Warnings ++
132
132
}
133
133
134
- //Ignore is used to mark the supplied FilePath as being ignored.
135
- //The most common reason for this is that the FilePath is Denied by the Ignores supplied to the Detector, however, Detectors may use more sophisticated reasons to ignore files.
134
+ // Ignore is used to mark the supplied FilePath as being ignored.
135
+ // The most common reason for this is that the FilePath is Denied by the Ignores supplied to the Detector, however, Detectors may use more sophisticated reasons to ignore files.
136
136
func (r * DetectionResults ) Ignore (filePath gitrepo.FilePath , category string ) {
137
137
138
138
isFilePresentInResults := false
@@ -176,12 +176,12 @@ func (r *DetectionResults) updateResultsSummary(category string, decr bool) {
176
176
}
177
177
}
178
178
179
- //HasFailures answers if any Failures were detected for any FilePath in the current run
179
+ // HasFailures answers if any Failures were detected for any FilePath in the current run
180
180
func (r * DetectionResults ) HasFailures () bool {
181
181
return r .Summary .Types .Filesize > 0 || r .Summary .Types .Filename > 0 || r .Summary .Types .Filecontent > 0
182
182
}
183
183
184
- //HasIgnores answers if any FilePaths were ignored in the current run
184
+ // HasIgnores answers if any FilePaths were ignored in the current run
185
185
func (r * DetectionResults ) HasIgnores () bool {
186
186
return r .Summary .Types .Ignores > 0
187
187
}
@@ -194,12 +194,12 @@ func (r *DetectionResults) HasDetectionMessages() bool {
194
194
return r .HasWarnings () || r .HasFailures () || r .HasIgnores ()
195
195
}
196
196
197
- //Successful answers if no detector was able to find any possible result to fail the run
197
+ // Successful answers if no detector was able to find any possible result to fail the run
198
198
func (r * DetectionResults ) Successful () bool {
199
199
return ! r .HasFailures ()
200
200
}
201
201
202
- //GetFailures returns the various reasons that a given FilePath was marked as failing by all the detectors in the current run
202
+ // GetFailures returns the various reasons that a given FilePath was marked as failing by all the detectors in the current run
203
203
func (r * DetectionResults ) GetFailures (fileName gitrepo.FilePath ) []Details {
204
204
results := r .getResultDetailsForFilePath (fileName )
205
205
if results == nil {
@@ -232,7 +232,7 @@ func (r *DetectionResults) ReportWarnings() string {
232
232
return results .String ()
233
233
}
234
234
235
- //Report returns a string documenting the various failures and ignored files for the current run
235
+ // Report returns a string documenting the various failures and ignored files for the current run
236
236
func (r * DetectionResults ) Report (promptContext prompt.PromptContext , mode string ) string {
237
237
var result string
238
238
var filePathsForFailures []string
@@ -273,7 +273,8 @@ func (r *DetectionResults) suggestTalismanRC(filePaths []string, promptContext p
273
273
274
274
if promptContext .Interactive && runtime .GOOS != "windows" {
275
275
confirmedEntries := getUserConfirmation (entriesToAdd , promptContext )
276
- talismanrc .ConfigFromFile ().AddIgnores (r .mode , confirmedEntries )
276
+ talismanrcConfig , _ := talismanrc .ConfigFromFile ()
277
+ talismanrcConfig .AddIgnores (r .mode , confirmedEntries )
277
278
278
279
for _ , confirmedEntry := range confirmedEntries {
279
280
resultsDetails := r .getResultDetailsForFilePath (gitrepo .FilePath (confirmedEntry .GetFileName ()))
@@ -329,7 +330,7 @@ func confirm(config talismanrc.IgnoreConfig, promptContext prompt.PromptContext)
329
330
return promptContext .Prompt .Confirm (confirmationString )
330
331
}
331
332
332
- //ReportFileFailures adds a string to table documenting the various failures detected on the supplied FilePath by all detectors in the current run
333
+ // ReportFileFailures adds a string to table documenting the various failures detected on the supplied FilePath by all detectors in the current run
333
334
func (r * DetectionResults ) ReportFileFailures (filePath gitrepo.FilePath ) [][]string {
334
335
failureList := r .getResultDetailsForFilePath (filePath ).FailureList
335
336
var data [][]string
0 commit comments