Skip to content

Commit

Permalink
Merge pull request #132 from kouprlabs/feat/enable-auto-fixable-linters
Browse files Browse the repository at this point in the history
Feature: enable auto fixable linters
  • Loading branch information
dsonck92 authored Jul 10, 2024
2 parents c46c6fc + 6c4ffcf commit f2ec471
Show file tree
Hide file tree
Showing 90 changed files with 520 additions and 413 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/build-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ on:
- "api/**"

jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Lint using Golanci lint
uses: golangci/golangci-lint-action@v6
with:
working-directory: api
permissions:
contents: read
pull-requests: read
checks: write

build_and_push:
runs-on: ubuntu-latest
steps:
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/build-conversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ on:
- "conversion/**"

jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Lint using Golanci lint
uses: golangci/golangci-lint-action@v6
with:
working-directory: conversion
permissions:
contents: read
pull-requests: read
checks: write

build_and_push:
runs-on: ubuntu-latest
steps:
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/build-mosaic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ on:
- "mosaic/**"

jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Lint using Golanci lint
uses: golangci/golangci-lint-action@v6
with:
working-directory: mosaic
permissions:
contents: read
pull-requests: read
checks: write

build_and_push:
runs-on: ubuntu-latest
steps:
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/build-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,6 @@ on:
- "ui/**"

jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Add dummy embedded files
run: |
mkdir ui/dist
touch ui/dist/index.html
- name: Lint using Golanci lint
uses: golangci/golangci-lint-action@v6
with:
working-directory: ui
permissions:
contents: read
pull-requests: read
checks: write

build_and_push:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/lint-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Add dummy embedded files
run: |
mkdir ui/dist
touch ui/dist/index.html
- name: Lint using Golanci lint
uses: golangci/golangci-lint-action@v6
with:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/lint-webdav.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 Daniël Sonck, Piotr Łoboda.
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the GNU Affero General Public License v3.0 only, included in the file
# licenses/AGPL.txt.

name: Lint voltaserve/webdav

on:
pull_request:
branches:
- main
paths:
- "webdav/**"

jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Lint using Golanci lint
uses: golangci/golangci-lint-action@v6
with:
working-directory: webdav
permissions:
contents: read
pull-requests: read
checks: write
6 changes: 1 addition & 5 deletions api/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ linters:
- asasalint
- bodyclose
- unparam
- tagalign
- revive
- predeclared
- interfacebloat
Expand All @@ -41,11 +40,8 @@ linters:
- nestif
- lll
- gosec
- gofumpt
- godot
- gocritic
- gocognit
- gci
- funlen
- forbidigo
- errcheck
Expand Down Expand Up @@ -78,7 +74,7 @@ linters-settings:
- standard
- default
- prefix(github.com/kouprlabs)
- prefix(github.com/kouprlabs/voltaserve)
- prefix(github.com/kouprlabs/voltaserve/api)

mnd:
ignored-numbers: ['2', '4', '8', '16', '32', '64', '10', '100', '1000']
Expand Down
4 changes: 2 additions & 2 deletions api/errorpkg/error_creators.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"net/http"
"strings"

"github.com/kouprlabs/voltaserve/api/model"

"github.com/go-playground/validator/v10"

"github.com/kouprlabs/voltaserve/api/model"
)

func NewGroupNotFoundError(err error) *ErrorResponse {
Expand Down
4 changes: 2 additions & 2 deletions api/errorpkg/error_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"errors"
"net/http"

"github.com/kouprlabs/voltaserve/api/log"

"github.com/gofiber/fiber/v2"

"github.com/kouprlabs/voltaserve/api/log"
)

func ErrorHandler(c *fiber.Ctx, err error) error {
Expand Down
7 changes: 3 additions & 4 deletions api/infra/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ import (
"io"
"os"
"path/filepath"

"github.com/kouprlabs/voltaserve/api/config"
"github.com/kouprlabs/voltaserve/api/log"
"text/template"

"gopkg.in/gomail.v2"
"sigs.k8s.io/yaml"

"text/template"
"github.com/kouprlabs/voltaserve/api/config"
"github.com/kouprlabs/voltaserve/api/log"
)

type MessageParams struct {
Expand Down
7 changes: 3 additions & 4 deletions api/infra/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
package infra

import (
"github.com/kouprlabs/voltaserve/api/config"

"gorm.io/driver/postgres"
"gorm.io/gorm"

"github.com/kouprlabs/voltaserve/api/config"
)

var db *gorm.DB

type PostgresManager struct {
}
type PostgresManager struct{}

func NewPostgresManager() *PostgresManager {
return &PostgresManager{}
Expand Down
4 changes: 2 additions & 2 deletions api/infra/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"context"
"strings"

"github.com/kouprlabs/voltaserve/api/config"

"github.com/redis/go-redis/v9"

"github.com/kouprlabs/voltaserve/api/config"
)

type RedisManager struct {
Expand Down
6 changes: 3 additions & 3 deletions api/infra/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
"io"
"strings"

"github.com/kouprlabs/voltaserve/api/config"
"github.com/kouprlabs/voltaserve/api/errorpkg"

"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"

"github.com/kouprlabs/voltaserve/api/config"
"github.com/kouprlabs/voltaserve/api/errorpkg"
)

type S3Manager struct {
Expand Down
4 changes: 2 additions & 2 deletions api/infra/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
package infra

import (
"github.com/kouprlabs/voltaserve/api/config"

"github.com/meilisearch/meilisearch-go"

"github.com/kouprlabs/voltaserve/api/config"
)

var searchClient *meilisearch.Client
Expand Down
7 changes: 4 additions & 3 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ import (
"os"
"strings"

jwtware "github.com/gofiber/contrib/jwt"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/joho/godotenv"

"github.com/kouprlabs/voltaserve/api/config"
"github.com/kouprlabs/voltaserve/api/errorpkg"
"github.com/kouprlabs/voltaserve/api/helper"
"github.com/kouprlabs/voltaserve/api/router"

jwtware "github.com/gofiber/contrib/jwt"
"github.com/joho/godotenv"
)

// @title Voltaserve API
// @version 2.0.0
// @BasePath /v2
//
// .
func main() {
if _, err := os.Stat(".env.local"); err == nil {
err := godotenv.Load(".env.local")
Expand Down
28 changes: 14 additions & 14 deletions api/repo/file_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"errors"
"time"

"gorm.io/gorm"

"github.com/kouprlabs/voltaserve/api/errorpkg"
"github.com/kouprlabs/voltaserve/api/helper"
"github.com/kouprlabs/voltaserve/api/infra"
"github.com/kouprlabs/voltaserve/api/model"

"gorm.io/gorm"
)

type FileRepo interface {
Expand Down Expand Up @@ -54,17 +54,17 @@ func NewFile() model.File {
}

type fileEntity struct {
ID string `json:"id" gorm:"column:id"`
WorkspaceID string `json:"workspaceId" gorm:"column:workspace_id"`
Name string `json:"name" gorm:"column:name"`
Type string `json:"type" gorm:"column:type"`
ParentID *string `json:"parentId,omitempty" gorm:"column:parent_id"`
UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"`
GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"`
Text *string `json:"text,omitempty" gorm:"-"`
SnapshotID *string `json:"snapshotId,omitempty" gorm:"column:snapshot_id"`
CreateTime string `json:"createTime" gorm:"column:create_time"`
UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"`
ID string `gorm:"column:id" json:"id"`
WorkspaceID string `gorm:"column:workspace_id" json:"workspaceId"`
Name string `gorm:"column:name" json:"name"`
Type string `gorm:"column:type" json:"type"`
ParentID *string `gorm:"column:parent_id" json:"parentId,omitempty"`
UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"`
GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"`
Text *string `gorm:"-" json:"text,omitempty"`
SnapshotID *string `gorm:"column:snapshot_id" json:"snapshotId,omitempty"`
CreateTime string `gorm:"column:create_time" json:"createTime"`
UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"`
}

func (*fileEntity) TableName() string {
Expand Down Expand Up @@ -223,7 +223,7 @@ func (repo *fileRepo) Find(id string) (model.File, error) {
}

func (repo *fileRepo) find(id string) (*fileEntity, error) {
var res = fileEntity{}
res := fileEntity{}
db := repo.db.Raw("SELECT * FROM file WHERE id = ?", id).Scan(&res)
if db.Error != nil {
if errors.Is(db.Error, gorm.ErrRecordNotFound) {
Expand Down
22 changes: 11 additions & 11 deletions api/repo/group_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"errors"
"time"

"gorm.io/gorm"

"github.com/kouprlabs/voltaserve/api/errorpkg"
"github.com/kouprlabs/voltaserve/api/helper"
"github.com/kouprlabs/voltaserve/api/infra"
"github.com/kouprlabs/voltaserve/api/model"

"gorm.io/gorm"
)

type GroupRepo interface {
Expand Down Expand Up @@ -47,14 +47,14 @@ func NewGroup() model.Group {
}

type groupEntity struct {
ID string `json:"id" gorm:"column:id"`
Name string `json:"name" gorm:"column:name"`
OrganizationID string `json:"organizationId" gorm:"column:organization_id"`
UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"`
GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"`
Members []string `json:"members" gorm:"-"`
CreateTime string `json:"createTime" gorm:"column:create_time"`
UpdateTime *string `json:"updateTime" gorm:"column:update_time"`
ID string `gorm:"column:id" json:"id"`
Name string `gorm:"column:name" json:"name"`
OrganizationID string `gorm:"column:organization_id" json:"organizationId"`
UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"`
GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"`
Members []string `gorm:"-" json:"members"`
CreateTime string `gorm:"column:create_time" json:"createTime"`
UpdateTime *string `gorm:"column:update_time" json:"updateTime"`
}

func (*groupEntity) TableName() string {
Expand Down Expand Up @@ -156,7 +156,7 @@ func (repo *groupRepo) Insert(opts GroupInsertOptions) (model.Group, error) {
}

func (repo *groupRepo) find(id string) (*groupEntity, error) {
var res = groupEntity{}
res := groupEntity{}
db := repo.db.Where("id = ?", id).First(&res)
if db.Error != nil {
if errors.Is(db.Error, gorm.ErrRecordNotFound) {
Expand Down
Loading

0 comments on commit f2ec471

Please sign in to comment.