stuttgart-things / machineshop

git based CLI interface for managing configuration as code
Apache License 2.0
1 stars 0 forks source link

[FIX] - LINITING ERRORS #90

Open patrick-hermann-sva opened 3 months ago

patrick-hermann-sva commented 3 months ago
level=warning msg="[config_reader] The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`."
internal/git.go:[7](https://github.com/stuttgart-things/machineshop/actions/runs/9219246421/job/25364061737#step:4:9)4:10: Error return value of `w.Commit` is not checked (errcheck)
    w.Commit(commitMsg, &git.CommitOptions{})
            ^
surveys/profiles.go:101:[8](https://github.com/stuttgart-things/machineshop/actions/runs/9219246421/job/25364061737#step:4:10)1: Error return value of `(github.com/pterm/pterm.TablePrinter).Render` is not checked (errcheck)
    pterm.DefaultTable.WithHasHeader().WithBoxed().WithData(repositoryTable).Render()
                                                                                   ^
cmd/create.go:100:25: Error return value of `sthingsCli.PushCommit` is not checked (errcheck)
            sthingsCli.PushCommit(client, ref, gitTree, groupName, repositoryName, authorName, authorEmail, commitMessage)
                                 ^
cmd/create.go:142:1: don't use `init` function (gochecknoinits)
func init() {
^
cmd/flow.go:16[9](https://github.com/stuttgart-things/machineshop/actions/runs/9219246421/job/25364061737#step:4:11):1: don't use `init` function (gochecknoinits)
func init() {
^
cmd/get.go:46:1: don't use `init` function (gochecknoinits)
func init() {
^
cmd/flow.go:58:16: string `git` has 4 occurrences, make it a constant (goconst)
        if source == "git" {
                     ^
internal/git.go:76:2: commentFormatting: put a space between `//` and comment text (gocritic)
    //Push the code to the remote
    ^
internal/git.go:57:2: commentedOutCode: may want to remove commented-out code (gocritic)
    // err = fs.Remove(filePath2)
    ^
surveys/install.go:42:21: builtinShadow: shadowing of predeclared identifier: error (gocritic)
                renderedScript, error := sthingsBase.RenderTemplateInline(string(scriptTemplate), "missingkey=error", "{{", "}}", allTemplateVariablesAndDefaults)
                                ^
surveys/install.go:92:5: nestingReduce: invert if cond, replace body with `continue`, move old body after the statement (gocritic)
                if binaryProfile[selectedProfile].Url != "" {
                ^
surveys/profiles.go:29:2: commentedOutCode: may want to remove commented-out code (gocritic)
    // allKeys := []string{}
    ^
surveys/profiles.go:39:4: commentedOutCode: may want to remove commented-out code (gocritic)
            // allKeys = append(allKeys, key)
            ^
surveys/profiles.go:58:5: sloppyLen: len(allBinaries) >= 0 is always true (gocritic)
    if len(allBinaries) >= 0 {
       ^
surveys/profiles.go:62:5: sloppyLen: len(allScripts) >= 0 is always true (gocritic)
    if len(allScripts) >= 0 {
       ^
surveys/release.go:28:5: nestingReduce: invert if cond, replace body with `continue`, move old body after the statement (gocritic)
                if repositoryProfile[selectedProfile].Url != "" {
                ^
internal/validation.go:22: File is not `gofmt`-ed with `-s` `-r 'interface{} -> any'` (gofmt)
func VerifyReadKeyValues(templateValues []string, log *sthingsBase.Logger, enableVault bool) map[string]interface{} {
cmd/flow.go:20: File is not `gofmt`-ed with `-s` `-r 'interface{} -> any'` (gofmt)
    defaults       = make(map[string]interface{})
cmd/render.go:30: File is not `gofmt`-ed with `-s` `-r 'interface{} -> any'` (gofmt)
    defaultVariables = make(map[string]interface{})
    flagVariables    = make(map[string]interface{})
internal/validation.go:20:7: G[10](https://github.com/stuttgart-things/machineshop/actions/runs/9219246421/job/25364061737#step:4:12)1: Potential hardcoded credentials (gosec)
const regexPatternVaultSecretPath = `.+/data/.+:.+`
      ^
internal/output.go:30: line is 144 characters (lll)
    pterm.DefaultCenter.Print(pterm.DefaultHeader.WithFullWidth().WithBackgroundStyle(pterm.NewStyle(pterm.BgLightCyan)).WithMargin(2).Sprint(cmd))
cmd/create.go:131: line is 171 characters (lll)
            err, pullRequestID := sthingsCli.CreatePullRequest(client, prSubject, prRepoOwner, sourceOwner, commitBranch, prRepo, sourceRepo, repoBranch, baseBranch, prDescription)
cmd/render.go:154: line is 158 characters (lll)
        renderedTemplate, err := sthingsBase.RenderTemplateInline(templateFile, renderOption, brackets[bracketFormat].begin, brackets[bracketFormat].end, variables)
cmd/root.go:43: line is 144 characters (lll)
    rootCmd.PersistentFlags().StringVar(&gitRepository, "git", "https://github.com/stuttgart-things/stuttgart-things.git", "source git repository")
surveys/install.go:107:13: `OVERWIRTE` is a misspelling of `OVERWRITE` (misspell)
                    // ADD OVERWIRTE OPTION
                           ^
cmd/root.go:28:24: `infrasturcture` is a misspelling of `infrastructure` (misspell)
    Short: "machineShop - infrasturcture cli",
                          ^
internal/output.go:44:95: unused-parameter: parameter 'overwrite' seems to be unused, consider removing or renaming it as _ (revive)
func HandleRenderOutput(outputFormat, destinationPath, renderedTemplate string, decodeBase64, overwrite bool) {
                                                                                              ^
cmd/render.go:44:32: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
    Run: func(cmd *cobra.Command, args []string) {
                                  ^
cmd/get.go:21:32: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
    Run: func(cmd *cobra.Command, args []string) {
                                  ^
cmd/flow.go:48:32: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
    Run: func(cmd *cobra.Command, args []string) {
                                  ^
internal/output.go:55:21: unnecessary conversion (unconvert)
        fmt.Println(string(renderedTemplate))
                          ^
internal/output.go:58:54: unnecessary conversion (unconvert)
        sthingsBase.WriteDataToFile(destinationPath, string(renderedTemplate))
                                                           ^
surveys/install.go:104:64: unnecessary conversion (unconvert)
                        renderedURL, _ := sthingsBase.RenderTemplateInline(string(url), "missingkey=zero", "{{", "}}", allTemplateVariablesAndDefaults)
                                                                                 ^
internal/git.go:17:[11](https://github.com/stuttgart-things/machineshop/actions/runs/9219246421/job/25364061737#step:4:13)6: unnecessary leading newline (whitespace)

^
internal/output.go:22:83: unnecessary leading newline (whitespace)

^
internal/output.go:61:1: unnecessary trailing newline (whitespace)

^
internal/validation.go:29:30: unnecessary leading newline (whitespace)

^
internal/validation.go:64:3: unnecessary trailing newline (whitespace)

^
internal/validation.go:101:2: unnecessary trailing newline (whitespace)

^
cmd/push.go:49:6: ineffectual assignment to target (ineffassign)
                    target = "orange"
                    ^
internal/output.go:18:87: Magic number: 50, in <argument> detected (mnd)
    logger = sthingsBase.StdOutFileLogger("/tmp/machineShop.log", "2006-01-02 15:04:05", 50, 3, 28)
                                                                                         ^
internal/validation.go:17:84: Magic number: 50, in <argument> detected (mnd)
    log = sthingsBase.StdOutFileLogger("/tmp/machineShop.log", "2006-01-02 15:04:05", 50, 3, 28)
                                                                                      ^
surveys/install.go:19:97: Magic number: 50, in <argument> detected (mnd)
    log              = sthingsBase.StdOutFileLogger("/tmp/machineShop.log", "2006-01-02 15:04:05", 50, 3, 28)
                                                                                                   ^
surveys/install.go:27:56: Magic number: 0600, in <argument> detected (mnd)
    sthingsBase.CreateNestedDirectoryStructure(scriptDir, 0600)
                                                          ^
surveys/install.go:84:62: Magic number: 0600, in <argument> detected (mnd)
        sthingsBase.CreateNestedDirectoryStructure(tmpDownloadDir, 0600)
                                                                   ^
surveys/install.go:[13](https://github.com/stuttgart-things/machineshop/actions/runs/9219246421/job/25364061737#step:4:15)2:104: Magic number: 0700, in <argument> detected (mnd)
                                sthingsCli.ExtractTarGzArchive(tmpDownloadDir+"/"+filepath.Base(url), tmpDownloadDir+"/"+name, 0700)
                                                                                                                               ^
surveys/install.go:152:63: Magic number: 0755, in <argument> detected (mnd)
                            sthingsBase.SetUnixFilePermissions(destinationBinPath, 0755)
                                                                                   ^
cmd/flow.go:61:61: Magic number: 0777, in <argument> detected (mnd)
            sthingsBase.CreateNestedDirectoryStructure(workspaceDir, 0777)
                                                                     ^
surveys/profiles.go:66:2: naked return in func `SelectInstallProfiles` with 40 lines of code (nakedret)
    return
    ^
internal/git.go:30:10: ST1005: error strings should not be capitalized (stylecheck)
        return fmt.Errorf("Could not git clone repository %s: %w", repository, err)
               ^
internal/git.go:37:10: ST1005: error strings should not be capitalized (stylecheck)
        return fmt.Errorf("Could not get git worktree: %w", err)
               ^
internal/git.go:45:10: ST1005: error strings should not be capitalized (stylecheck)
        return fmt.Errorf("Could not create new file: %w", err)
               ^
surveys/profiles.go:[14](https://github.com/stuttgart-things/machineshop/actions/runs/9219246421/job/25364061737#step:4:16):2: ST1003: struct field Url should be URL (stylecheck)
    Url string `mapstructure:"url"`
    ^
surveys/profiles.go:71:2: ST1003: struct field Url should be URL (stylecheck)
    Url     string `mapstructure:"url"`
    ^