linter: enable errchkjson

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg committed 2022-03-22 13:04:35 +01:00
1 parent bb6b69b4ab
commit f72a678f2a
3 files changed
+7 -4

No files matched your search

-1
View File
@@ -62,7 +62,6 @@ linters:
- ireturn
- tagliatelle
- varnamelen
- errchkjson
- maintidx
- nilerr
- nilnil
+3 -2
View File
@@ -102,9 +102,10 @@ var _ = Describe("Common functions test", func() {
Item2: []string{"test"},
}
testByte, _ := json.Marshal(testData)
err := WriteJSONFile(testByte, "/tmp/testJSON")
testByte, err := json.Marshal(testData)
Expect(err).To(BeNil(), "Failed to marshal data.")
err = WriteJSONFile(testByte, "/tmp/testJSON")
Expect(err).To(BeNil(), "Failed to write JSON to file.")
read, err := os.Open("/tmp/testJSON")
+4 -1
View File
@@ -479,7 +479,10 @@ func IsCommandAvailable(command string) bool {
func WriteJSONFile(data []byte, filePath string) error {
var jsonData map[string]interface{}
json.Unmarshal(data, &jsonData)
formatJSON, _ := json.MarshalIndent(jsonData, "", " ")
formatJSON, err := json.MarshalIndent(jsonData, "", " ")
if err != nil {
return err
}
return ioutil.WriteFile(filePath, formatJSON, 0644)
}