diff --git a/SCC-OUTPUT-REPORT.html b/SCC-OUTPUT-REPORT.html index 544a0d8c3..423e0bc3f 100644 --- a/SCC-OUTPUT-REPORT.html +++ b/SCC-OUTPUT-REPORT.html @@ -13,13 +13,13 @@ Go 30 - 9515 - 1460 - 456 - 7599 - 1516 - 254099 - 4050 + 9627 + 1481 + 468 + 7678 + 1536 + 256617 + 4092 processor/formatters.go @@ -93,13 +93,13 @@ cmd/badges/main.go - 342 + 345 59 14 - 269 - 47 - 7991 - 202 + 272 + 50 + 8129 + 204 processor/workers_tokei_test.go @@ -113,13 +113,13 @@ processor/detector.go - 236 + 237 44 33 - 159 + 160 57 - 6232 - 151 + 6243 + 152 processor/file_test.go @@ -160,6 +160,16 @@ 50 3766 99 + + cmd/badges/simplecache.go + + 161 + 28 + 13 + 120 + 20 + 3070 + 94 processor/processor_test.go @@ -181,15 +191,15 @@ 1911 60 - cmd/badges/simplecache.go + cmd/badges/simplecache_test.go - 109 + 102 + 21 + 3 + 78 17 - 4 - 88 - 14 - 1931 - 75 + 2024 + 52 processor/structs_test.go @@ -203,13 +213,13 @@ scripts/include.go - 76 - 15 - 8 - 53 + 82 16 - 1796 - 56 + 8 + 58 + 19 + 2043 + 60 processor/processor_unix.go @@ -230,16 +240,6 @@ 6 1316 37 - - cmd/badges/simplecache_test.go - - 52 - 12 - 0 - 40 - 9 - 1041 - 30 processor/cocomo.go @@ -250,16 +250,6 @@ 0 2209 35 - - processor/bloom.go - - 37 - 7 - 12 - 18 - 2 - 1062 - 29 processor/cocomo_test.go @@ -270,6 +260,16 @@ 6 686 23 + + processor/bloom.go + + 37 + 7 + 12 + 18 + 2 + 1062 + 29 processor/helpers_test.go @@ -324,15 +324,15 @@ Total 30 - 9515 - 1460 - 456 - 7599 - 1516 - 254099 - 4050 + 9627 + 1481 + 468 + 7678 + 1536 + 256617 + 4092 - Estimated Cost to Develop (organic) $227,190
Estimated Schedule Effort (organic) 7.83 months
Estimated People Required (organic) 2.58
+ Estimated Cost to Develop (organic) $229,670
Estimated Schedule Effort (organic) 7.86 months
Estimated People Required (organic) 2.59
\ No newline at end of file diff --git a/cmd/badges/main.go b/cmd/badges/main.go index d2c125f66..89fd7b42f 100644 --- a/cmd/badges/main.go +++ b/cmd/badges/main.go @@ -67,7 +67,10 @@ func main() { addr := ":8080" log.Info().Str(uniqueCode, "1876ce1e").Str("addr", addr).Msg("serving") - http.ListenAndServe(addr, nil).Error() + if err := http.ListenAndServe(addr, nil); err != nil && !errors.Is(err, http.ErrServerClosed) { + log.Error().Str(uniqueCode, "c28556e8").Err(err).Send() + os.Exit(1) + } } func calculate(category string, wage int, res []processor.LanguageSummary) (string, int64) { diff --git a/processor/detector.go b/processor/detector.go index 633c907b8..6696bb9f6 100644 --- a/processor/detector.go +++ b/processor/detector.go @@ -89,6 +89,7 @@ func scanForSheBang(content []byte) (string, error) { candidate1 := "" candidate2 := "" +loop: for i := range content { switch state { case 0: // Deals with whitespace after #! and before first / @@ -128,7 +129,7 @@ func scanForSheBang(content []byte) (string, error) { state = 4 } case 4: - break + break loop } } diff --git a/processor/formatters.go b/processor/formatters.go index 4556256eb..1db3d7328 100644 --- a/processor/formatters.go +++ b/processor/formatters.go @@ -843,7 +843,7 @@ func fileSummarizeMulti(input chan *FileJob) string { } close(i) - var val = "" + var val string switch strings.ToLower(t[0]) { case "tabular": @@ -861,8 +861,8 @@ func fileSummarizeMulti(input chan *FileJob) string { case "csv": val = toCSV(i) case "csv-stream": - val = toCSVStream(i) // special case where we want to ignore writing to stdout to disk as it's already done + _ = toCSVStream(i) continue case "html": val = toHtml(i) diff --git a/scripts/include.go b/scripts/include.go index 7a9484e69..04c5e0ccf 100644 --- a/scripts/include.go +++ b/scripts/include.go @@ -3,6 +3,7 @@ package main import ( + "bytes" "compress/gzip" "encoding/base64" "encoding/json" @@ -18,14 +19,10 @@ const constantsFile = "./processor/constants.go" // and encodes them as strings literals in constants.go func generateConstants() error { files, _ := os.ReadDir(".") - out, err := os.CreateTemp(".", "temp_constants") - if err != nil { - return fmt.Errorf("failed to open temp file: %v", err) - } - defer os.Remove(out.Name()) + buf := &bytes.Buffer{} // Open constants - out.WriteString("package processor \n\nconst (\n") + _, _ = buf.WriteString("package processor\n\nconst (\n") for _, f := range files { if strings.HasPrefix(f.Name(), "languages") && strings.HasSuffix(f.Name(), ".json") { @@ -33,6 +30,7 @@ func generateConstants() error { if err != nil { return fmt.Errorf("failed to open file '%s': %v", f.Name(), err) } + defer f.Close() // validate the json by decoding into an empty struct if err := json.NewDecoder(f).Decode(&struct{}{}); err != nil { @@ -40,12 +38,15 @@ func generateConstants() error { } // Reset position - f.Seek(0, io.SeekStart) + if _, err := f.Seek(0, io.SeekStart); err != nil { + return fmt.Errorf("failed to reset file position '%s': %v", f.Name(), err) + } // The constant variable name - out.WriteString(strings.TrimSuffix(f.Name(), ".json") + " = `") + _ = buf.WriteByte('\t') + _, _ = buf.WriteString(strings.TrimSuffix(f.Name(), ".json") + " = `") - enc := base64.NewEncoder(base64.StdEncoding, out) + enc := base64.NewEncoder(base64.StdEncoding, buf) gz, _ := gzip.NewWriterLevel(enc, gzip.BestSpeed) if _, err := io.Copy(gz, f); err != nil { return fmt.Errorf("failed to encode file '%s': %v", f.Name(), err) @@ -53,16 +54,21 @@ func generateConstants() error { gz.Close() enc.Close() - out.WriteString("`\n") + _, _ = buf.WriteString("`\n") } } // Close out constants - out.WriteString(")\n") - out.Close() + _, _ = buf.WriteString(")\n") + + out, err := os.OpenFile(constantsFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + if err != nil { + return fmt.Errorf("failed to open constants file: %v", err) + } + defer out.Close() - if err := os.Rename(out.Name(), constantsFile); err != nil { - return fmt.Errorf("%v", err) + if _, err := io.Copy(out, buf); err != nil { + return fmt.Errorf("failed to write constants file %v", err) } return nil