Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactoring of code to meet all golangci-lint requirements #134

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint

on:
push:
pull_request:

jobs:
lint:
name: Run on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.22'

- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
44 changes: 44 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
run:
timeout: 5m
allow-parallel-runners: true

issues:
# don't skip warning about doc comments
# don't exclude the default set of lint
exclude-use-default: false
# restore some of the defaults
# (fill in the rest as needed)
exclude-rules:
- path: "internal/*"
linters:
- dupl
- lll
- goimports
linters:
disable-all: true
enable:
- dupl
- errcheck
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
- gofmt
- gosimple
- govet
- ineffassign
# - lll
- misspell
- nakedret
- prealloc
- revive
- staticcheck
- typecheck
- unconvert
- unparam
- unused

linters-settings:
revive:
rules:
- name: comment-spacings
10 changes: 3 additions & 7 deletions cmd/backup.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// Package cmd /
/*****
@author Jonas Kaninda
@license MIT License <https://opensource.org/licenses/MIT>
@Copyright © 2024 Jonas Kaninda
**/
package cmd

import (
"github.com/jkaninda/pg-bkup/internal"
"github.com/jkaninda/pg-bkup/pkg/logger"
"github.com/jkaninda/pg-bkup/utils"
"github.com/spf13/cobra"
)
Expand All @@ -20,14 +16,14 @@ var BackupCmd = &cobra.Command{
if len(args) == 0 {
internal.StartBackup(cmd)
} else {
utils.Fatal(`"backup" accepts no argument %q`, args)
logger.Fatal(`"backup" accepts no argument %q`, args)

}
},
}

func init() {
//Backup
// Backup
BackupCmd.PersistentFlags().StringP("storage", "s", "local", "Define storage: local, s3, ssh, ftp")
BackupCmd.PersistentFlags().StringP("path", "P", "", "AWS S3 path without file name. eg: /custom_path or ssh remote path `/home/foo/backup`")
BackupCmd.PersistentFlags().StringP("cron-expression", "", "", "Backup cron expression")
Expand Down
7 changes: 4 additions & 3 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Package cmd /
/*****
/*
****
@author Jonas Kaninda
@license MIT License <https://opensource.org/licenses/MIT>
@Copyright © 2024 Jonas Kaninda
Expand All @@ -8,7 +9,7 @@ package cmd

import (
"github.com/jkaninda/pg-bkup/internal"
"github.com/jkaninda/pg-bkup/utils"
"github.com/jkaninda/pg-bkup/pkg/logger"
"github.com/spf13/cobra"
)

Expand All @@ -19,7 +20,7 @@ var MigrateCmd = &cobra.Command{
if len(args) == 0 {
internal.StartMigration(cmd)
} else {
utils.Fatal(`"migrate" accepts no argument %q`, args)
logger.Fatal(`"migrate" accepts no argument %q`, args)

}

Expand Down
8 changes: 5 additions & 3 deletions cmd/restore.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Package cmd /
/*****
/*
****
@author Jonas Kaninda
@license MIT License <https://opensource.org/licenses/MIT>
@Copyright © 2024 Jonas Kaninda
Expand All @@ -8,6 +9,7 @@ package cmd

import (
"github.com/jkaninda/pg-bkup/internal"
"github.com/jkaninda/pg-bkup/pkg/logger"
"github.com/jkaninda/pg-bkup/utils"
"github.com/spf13/cobra"
)
Expand All @@ -20,15 +22,15 @@ var RestoreCmd = &cobra.Command{
if len(args) == 0 {
internal.StartRestore(cmd)
} else {
utils.Fatal(`"restore" accepts no argument %q`, args)
logger.Fatal(`"restore" accepts no argument %q`, args)

}

},
}

func init() {
//Restore
// Restore
RestoreCmd.PersistentFlags().StringP("file", "f", "", "File name of database")
RestoreCmd.PersistentFlags().StringP("storage", "s", "local", "Define storage: local, s3, ssh, ftp")
RestoreCmd.PersistentFlags().StringP("path", "P", "", "AWS S3 path without file name. eg: /custom_path or ssh remote path `/home/foo/backup`")
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Package cmd /
/*****
/*
*
***
@author Jonas Kaninda
@license MIT License <https://opensource.org/licenses/MIT>
@Copyright © 2024 Jonas Kaninda
Expand Down
3 changes: 2 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Package cmd /
/*****
/*
****
@author Jonas Kaninda
@license MIT License <https://opensource.org/licenses/MIT>
@Copyright © 2024 Jonas Kaninda
Expand Down
Loading