Fix formatting issues with gofumpt (#685)

Signed-off-by: Cosmin Cojocar <ccojocar@cloudbees.com>
This commit is contained in:
Cosmin Cojocar 2021-08-18 13:16:21 +02:00 committed by GitHub
parent ba23b5e49a
commit f285d612b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View file

@ -187,7 +187,7 @@ func main() {
} }
outputPath := filepath.Join(dir, *outputFile) outputPath := filepath.Join(dir, *outputFile)
if err := ioutil.WriteFile(outputPath, src, 0644); err != nil { if err := ioutil.WriteFile(outputPath, src, 0o644); err != nil {
log.Fatalf("Writing output: %s", err) log.Fatalf("Writing output: %s", err)
} // #nosec G306 } // #nosec G306
} }

View file

@ -39,7 +39,7 @@ var _ = Describe("Helpers", func() {
}) })
It("should exclude folder", func() { It("should exclude folder", func() {
nested := dir + "/vendor" nested := dir + "/vendor"
err := os.Mkdir(nested, 0755) err := os.Mkdir(nested, 0o755)
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
_, err = os.Create(nested + "/test.go") _, err = os.Create(nested + "/test.go")
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
@ -51,7 +51,7 @@ var _ = Describe("Helpers", func() {
}) })
It("should exclude folder with subpath", func() { It("should exclude folder with subpath", func() {
nested := dir + "/pkg/generated" nested := dir + "/pkg/generated"
err := os.MkdirAll(nested, 0755) err := os.MkdirAll(nested, 0o755)
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
_, err = os.Create(nested + "/test.go") _, err = os.Create(nested + "/test.go")
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())

View file

@ -64,7 +64,7 @@ func (r *filePermissions) Match(n ast.Node, c *gosec.Context) (*gosec.Issue, err
// NewWritePerms creates a rule to detect file Writes with bad permissions. // NewWritePerms creates a rule to detect file Writes with bad permissions.
func NewWritePerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) { func NewWritePerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) {
mode := getConfiguredMode(conf, "G306", 0600) mode := getConfiguredMode(conf, "G306", 0o600)
return &filePermissions{ return &filePermissions{
mode: mode, mode: mode,
pkgs: []string{"io/ioutil", "os"}, pkgs: []string{"io/ioutil", "os"},
@ -81,7 +81,7 @@ func NewWritePerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) {
// NewFilePerms creates a rule to detect file creation with a more permissive than configured // NewFilePerms creates a rule to detect file creation with a more permissive than configured
// permission mask. // permission mask.
func NewFilePerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) { func NewFilePerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) {
mode := getConfiguredMode(conf, "G302", 0600) mode := getConfiguredMode(conf, "G302", 0o600)
return &filePermissions{ return &filePermissions{
mode: mode, mode: mode,
pkgs: []string{"os"}, pkgs: []string{"os"},
@ -98,7 +98,7 @@ func NewFilePerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) {
// NewMkdirPerms creates a rule to detect directory creation with more permissive than // NewMkdirPerms creates a rule to detect directory creation with more permissive than
// configured permission mask. // configured permission mask.
func NewMkdirPerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) { func NewMkdirPerms(id string, conf gosec.Config) (gosec.Rule, []ast.Node) {
mode := getConfiguredMode(conf, "G301", 0750) mode := getConfiguredMode(conf, "G301", 0o750)
return &filePermissions{ return &filePermissions{
mode: mode, mode: mode,
pkgs: []string{"os"}, pkgs: []string{"os"},

View file

@ -53,7 +53,7 @@ func (p *TestPackage) write() error {
return nil return nil
} }
for filename, content := range p.Files { for filename, content := range p.Files {
if e := ioutil.WriteFile(filename, []byte(content), 0644); e != nil { if e := ioutil.WriteFile(filename, []byte(content), 0o644); e != nil {
return e return e
} // #nosec G306 } // #nosec G306
} }