Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
Follow up #40
  • Loading branch information
minamijoyo committed Jan 6, 2022
1 parent 3dcce57 commit 9536d9c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions cmd/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func newAttributeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "attribute",
Short: "Edit attribute",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help() // nolint: errcheck
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}

Expand Down Expand Up @@ -147,7 +147,7 @@ Arguments:

flags := cmd.Flags()
flags.Bool("newline", false, "Append a new line before a new attribute")
viper.BindPFlag("attribute.append.newline", flags.Lookup("newline")) // nolint: errcheck
_ = viper.BindPFlag("attribute.append.newline", flags.Lookup("newline"))

return cmd
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func newBlockCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "block",
Short: "Edit block",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help() // nolint: errcheck
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}

Expand Down Expand Up @@ -163,7 +163,7 @@ Arguments:

flags := cmd.Flags()
flags.Bool("newline", false, "Append a new line before a new child block")
viper.BindPFlag("block.append.newline", flags.Lookup("newline")) // nolint: errcheck
_ = viper.BindPFlag("block.append.newline", flags.Lookup("newline"))

return cmd
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/body.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func newBodyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "body",
Short: "Edit body",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help() // nolint: errcheck
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func init() {
flags := RootCmd.PersistentFlags()
flags.StringP("file", "f", "-", "A path of input file")
flags.BoolP("update", "u", false, "Update files in-place")
viper.BindPFlag("file", flags.Lookup("file")) // nolint: errcheck
viper.BindPFlag("update", flags.Lookup("update")) // nolint: errcheck
_ = viper.BindPFlag("file", flags.Lookup("file"))
_ = viper.BindPFlag("update", flags.Lookup("update"))

setDefaultStream(RootCmd)
}
Expand Down
2 changes: 1 addition & 1 deletion editor/filter_vertical_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func trimLeadingNewLine(tokens hclwrite.Tokens) hclwrite.Tokens {
}
}

return tokens[begin:len(tokens)] // nolint: gosimple
return tokens[begin:]
}

// removeDuplicatedNewLine removes duplicated newlines
Expand Down
3 changes: 1 addition & 2 deletions editor/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ func setupTestFile(t *testing.T, contents string) string {
path := f.Name()
t.Cleanup(func() { os.Remove(path) })

// nolint: gosec
if err := os.WriteFile(path, []byte(contents), 0644); err != nil {
if err := os.WriteFile(path, []byte(contents), 0600); err != nil {
t.Fatalf("failed to write test file: %s", err)
}

Expand Down
8 changes: 6 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ func TestHCLEditMain(t *testing.T) {
// So that the second run is able to run main() and this first run can verify the exit status returned by that.
//
// This technique originates from https://talks.golang.org/2014/testing.slide#23.
cmd := exec.Command(os.Args[0], "-test.run=TestHCLEditMain") // nolint: gosec
self, err := os.Executable()
if err != nil {
t.Fatal(err)
}
cmd := exec.Command(self, "-test.run=TestHCLEditMain")
cmd.Env = append(
cmd.Env,
os.Environ()...,
Expand All @@ -112,7 +116,7 @@ func TestHCLEditMain(t *testing.T) {
cmd.Stdout = stdout
cmd.Stderr = stderr

err := cmd.Run()
err = cmd.Run()

if got := stdout.String(); got != tc.wantStdout {
t.Errorf("Unexpected stdout: want %q, got %q", tc.wantStdout, got)
Expand Down

0 comments on commit 9536d9c

Please sign in to comment.