Skip to content

Commit

Permalink
Added also linting and more rules to deal better with several platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed Aug 24, 2024
1 parent e261c9d commit 1b30ca3
Show file tree
Hide file tree
Showing 128 changed files with 718 additions and 299 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{go,go.tmpl}]
indent_style = tab
indent_size = 4

[*.{yaml,yml}]
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.go text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
*.json text eol=lf
*.sh text eol=lf
*.md text eol=lf

3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Continuous Integration

on:
push:

Expand All @@ -13,7 +12,7 @@ jobs:
name: Tests
strategy:
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint
on:
push:

pull_request:
types:
- opened
- reopened

permissions:
contents: read

jobs:
golangci:
name: "golangci-lint"
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
run:
timeout: 20m

linters:
enable:
- asasalint
- asciicheck
- bidichk
- misspell
disable:
- ineffassign

linters-settings:
misspell:
locale: US
ignore-words:
- engity
- bifröst
- bifroest

issues:
exclude-dirs:
- internal/fmtsort
- internal/text
exclude:
- S1002
- S1016
- SA1012
- S1031
- SA1019
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions cmd/bifroest/dummy-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package main
import (
"context"
"fmt"
"github.com/alecthomas/kingpin"
log "github.com/echocat/slf4g"
"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/errors"
"net"
"net/http"
"os"
"os/signal"
"strings"
"syscall"

"github.com/alecthomas/kingpin"
log "github.com/echocat/slf4g"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/errors"
)

var (
Expand Down Expand Up @@ -83,7 +85,7 @@ func dummyServerHandleIndex(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodHead {
return
}
_, err = fmt.Fprintf(w, `Hello from a dummy-server!
_, _ = fmt.Fprintf(w, `Hello from a dummy-server!
Called URI: %v
Method: %v
Expand Down
6 changes: 4 additions & 2 deletions cmd/bifroest/sftp-server.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"os"

"github.com/alecthomas/kingpin"

"github.com/engity-com/bifroest/pkg/sftp"
"os"
)

var (
Expand Down Expand Up @@ -53,7 +55,7 @@ func (this *stdpipe) Close() (rErr error) {
rErr = err
}
if err := os.Stdout.Close(); err != nil && rErr == nil {
rErr = err
rErr = err //nolint:golint,staticcheck
}
return nil
}
10 changes: 5 additions & 5 deletions cmd/bifroest/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package main

import (
"fmt"
"github.com/alecthomas/kingpin"
"github.com/engity-com/bifroest/pkg/common"
"os"
"runtime"
"strings"
"time"

"github.com/alecthomas/kingpin"

"github.com/engity-com/bifroest/pkg/common"
)

var (
Expand Down Expand Up @@ -95,9 +97,7 @@ func (this versionT) Vendor() string {
}

func (this versionT) GoVersion() string {
v := runtime.Version()
strings.TrimPrefix(v, "go")
return v
return strings.TrimPrefix(runtime.Version(), "go")
}

func (this versionT) Platform() string {
Expand Down
2 changes: 1 addition & 1 deletion internal/text/template/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ func testExecute(execTests []execTest, template *Template, t *testing.T) {
fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
}
}
result := b.String()
result := strings.ReplaceAll(b.String(), "\r\n", "\n")
if result != test.output {
t.Errorf("%s: expected\n\t%q\ngot\n\t%q", test.name, test.output, result)
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/authorization/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package authorization

import (
"context"

"golang.org/x/crypto/ssh"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/configuration"
"github.com/engity-com/bifroest/pkg/session"
"github.com/engity-com/bifroest/pkg/sys"
"golang.org/x/crypto/ssh"
)

type Authorization interface {
Expand Down
4 changes: 3 additions & 1 deletion pkg/authorization/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package authorization
import (
"context"
"errors"
"io"

log "github.com/echocat/slf4g"

"github.com/engity-com/bifroest/pkg/session"
"io"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/authorization/facade-authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package authorization
import (
"context"
"fmt"
"reflect"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/configuration"
"github.com/engity-com/bifroest/pkg/errors"
"github.com/engity-com/bifroest/pkg/session"
"reflect"
)

func NewAuthorizerFacade(ctx context.Context, flows *configuration.Flows) (*AuthorizerFacade, error) {
Expand Down
9 changes: 2 additions & 7 deletions pkg/authorization/htpasswd-authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"encoding/json"
"fmt"

log "github.com/echocat/slf4g"

"github.com/engity-com/bifroest/pkg/configuration"
"github.com/engity-com/bifroest/pkg/errors"
"github.com/engity-com/bifroest/pkg/session"
Expand Down Expand Up @@ -244,10 +246,3 @@ func (this *HtpasswdAuthorizer) RestoreFromSession(ctx context.Context, sess ses
func (this *HtpasswdAuthorizer) Close() error {
return nil
}

func (this *HtpasswdAuthorizer) logger() log.Logger {
if v := this.Logger; v != nil {
return v
}
return log.GetLogger("authorizer")
}
4 changes: 3 additions & 1 deletion pkg/authorization/htpasswd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package authorization
import (
"context"
"fmt"

"golang.org/x/crypto/ssh"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/configuration"
"github.com/engity-com/bifroest/pkg/session"
"github.com/engity-com/bifroest/pkg/sys"
"golang.org/x/crypto/ssh"
)

type htpasswd struct {
Expand Down
Loading

0 comments on commit 1b30ca3

Please sign in to comment.