Skip to content

Commit

Permalink
Merge pull request #19 from kcmvp/lint
Browse files Browse the repository at this point in the history
fix lint issue
  • Loading branch information
kcmvp authored Dec 25, 2023
2 parents 16c9e7d + bc2aebb commit a22cccd
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 37 deletions.
14 changes: 2 additions & 12 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ run:
tests: false
output:
sort-results: true
format: tab
format: html
linters:
enable-all: false
disable-all: true
enable:
- deadcode
- errcheck
Expand All @@ -19,13 +19,3 @@ linters:
- gofumpt
- nosnakecase
- goconst
presets:
- bugs
- comment
- complexity
- error
- metalinter
- module
- performance
- sql
- unused
6 changes: 3 additions & 3 deletions cmd/builder/builder_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const (
)

var builtinActions = []shared.CmdAction{
{"build", buildCommand},
{"clean", cleanCommand},
{"test", testCommand},
{A: "build", B: buildCommand},
{A: "clean", B: cleanCommand},
{A: "test", B: testCommand},
}

func findMain(dir string) (string, error) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ func exec(execution internal.Execution, cmd *cobra.Command, args ...string) erro
args = append(args, execution.Actions...)
return validateCommitMsg(cmd, args...)
} else {
var err error
for _, action := range execution.Actions {
for _, cmdAction := range builder.Actions() {
if action == cmdAction.A {
if err := cmdAction.B(cmd, args...); err != nil {
if err = cmdAction.B(cmd, args...); err != nil {
return err
}
}
}
}
return err
}
return nil
}

// execCmd represents the exec command
Expand Down
1 change: 0 additions & 1 deletion cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var installPluginCmd = &cobra.Command{
func init() {
// init pluginCmd
builderCmd.AddCommand(pluginCmd)
pluginCmd.Flags().BoolVarP(&plugin.UpdateList, "update", "u", false, "update configured plugins")

// init installPluginCmd
pluginCmd.AddCommand(installPluginCmd)
Expand Down
17 changes: 3 additions & 14 deletions cmd/resources/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ run:
tests: false
output:
sort-results: true
format: tab
format: html
linters:
enable-all: false
disable-all: true
enable:
- deadcode
- errcheck
Expand All @@ -14,18 +14,7 @@ linters:
- ineffassign
- staticcheck
- unused
- varcheck
- gosec
- gofumpt
- nosnakecase
- goconst
presets:
- bugs
- comment
- complexity
- error
- metalinter
- module
- performance
- sql
- unused
- revive
2 changes: 1 addition & 1 deletion cmd/shared/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func execPlugin(cmd *cobra.Command, args ...string) error {
exeCmd := exec.Command(plugin.B, lo.Map(cmds, func(cmd string, _ int) string {
return strings.TrimSpace(cmd)
})...)
return StreamExtCmdOutput(exeCmd, filepath.Join(internal.CurProject().Target(), fmt.Sprintf("%s.log", args[0])), "")
return StreamExtCmdOutput(exeCmd, filepath.Join(internal.CurProject().Target(), fmt.Sprintf("%s.html", args[0])), "")
}

func PluginActions() []CmdAction {
Expand Down
8 changes: 4 additions & 4 deletions internal/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (project *Project) Plugins() []lo.Tuple4[string, string, string, string] {
attr := value.(map[string]any)
//@todo validate attribute for null or empty
return lo.Tuple4[string, string, string, string]{
key, attr["alias"].(string), attr["command"].(string), attr["url"].(string),
A: key, B: attr["alias"].(string), C: attr["command"].(string), D: attr["url"].(string),
}
})
} else {
Expand Down Expand Up @@ -226,9 +226,9 @@ func (project *Project) PluginCommands() []lo.Tuple3[string, string, string] {
cmd, _ := lo.Last(strings.Split(plugin.D, "/"))
cmd = strings.ReplaceAll(cmd, "@", "-")
return lo.Tuple3[string, string, string]{
plugin.B,
cmd,
plugin.C,
A: plugin.B,
B: cmd,
C: plugin.C,
}
})
}
Expand Down

0 comments on commit a22cccd

Please sign in to comment.