Skip to content

Commit 9f7a6a8

Browse files
authored
import code-lint workflow job (bfenetworks#1037)
Signed-off-by: kwanhur <[email protected]>
1 parent 83f5433 commit 9f7a6a8

File tree

22 files changed

+69
-66
lines changed

22 files changed

+69
-66
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
steps:
3636
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3737
- name: Checkout repository
38-
uses: actions/checkout@v2
38+
uses: actions/checkout@v3
3939
with:
4040
# Must fetch at least the immediate parents so that if this is
4141
# a pull request then we can checkout the head of the pull request.

.github/workflows/code-lint.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2022 The BFE Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
name: Code Lint
16+
17+
on:
18+
pull_request:
19+
branches: [ develop ]
20+
paths-ignore:
21+
- 'docs/**'
22+
- '**/*.md'
23+
24+
jobs:
25+
lint:
26+
name: Code lint
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 10
29+
steps:
30+
- uses: actions/checkout@v3
31+
- uses: dominikh/[email protected]
32+
with:
33+
version: "2021.1.1"
34+
- run: "go vet ./..."

.github/workflows/docs-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
timeout-minutes: 1
2828
steps:
29-
- uses: actions/checkout@v2.4.0
29+
- uses: actions/checkout@v3
3030
- name: Use Node.js
3131
uses: actions/[email protected]
3232
with:

bfe_config/bfe_cluster_conf/cluster_conf/cluster_conf_load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type BackendCheck struct {
7575
CheckInterval *int // interval of health check, in ms
7676
}
7777

78-
// FastCGI related configurations
78+
// FCGIConf are FastCGI related configurations
7979
type FCGIConf struct {
8080
EnvVars map[string]string // the vars which will send to backend
8181
Root string // the server root

bfe_fcgi/fcgi_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (rec *record) read(r io.Reader) (buf []byte, err error) {
180180
if len(rec.rbuf) < n {
181181
rec.rbuf = make([]byte, n)
182182
}
183-
if n, err = io.ReadFull(r, rec.rbuf[:n]); err != nil {
183+
if _, err = io.ReadFull(r, rec.rbuf[:n]); err != nil {
184184
return
185185
}
186186
buf = rec.rbuf[:int(rec.h.ContentLength)]

bfe_http/request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const (
5555
// is either not present in the request or not a file field.
5656
var ErrMissingFile = errors.New("http: no such file")
5757

58-
// HTTP request parsing errors.
58+
// ProtocolError is the error found during HTTP request parsing.
5959
type ProtocolError struct {
6060
ErrorString string
6161
}

bfe_http2/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) {
411411
return
412412
}
413413

414+
//lint:ignore SA9003 empty branch
414415
if sc.tlsState.ServerName == "" {
415416
// Client must use SNI, but we don't enforce that anymore,
416417
// since it was causing problems when connecting to bare IP

bfe_modules/mod_auth_request/auth_request_rule_load.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ import (
2424
"github.com/bfenetworks/bfe/bfe_util/json"
2525
)
2626

27-
// rule loaded from file
2827
type AuthRequestRuleFile struct {
2928
Version string
3029
Config ProductRuleRawList // product => raw rule list
3130
}
3231

33-
// rule conf parsed from rule file
3432
type AuthRequestRuleConf struct {
3533
Version string
3634
Config ProductRuleList // product => rule list

bfe_modules/mod_markdown/mod_markdown_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ func TestModuleMarkdown_renderMarkDownHandler(t *testing.T) {
131131
t.Errorf("ModuleMarkdown.TestModuleMarkdown_renderMarkDownHandler() error = %v", err)
132132
}
133133
want, err := ioutil.ReadFile(targetPath)
134+
if err != nil {
135+
t.Errorf("ModuleMarkdown.TestModuleMarkdown_renderMarkDownHandler() error = %v", err)
136+
}
134137
if !reflect.DeepEqual(got, want) {
135138
t.Errorf("ModuleMarkdown.TestModuleMarkdown_renderMarkDownHandler(), got[%s], want[%s]", string(got), string(want))
136139
}

bfe_modules/mod_redirect/action.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type Action struct {
3636

3737
type ActionFileList []ActionFile
3838

39-
// exclusive action set
4039
var EXCLUSIVE_ACTIONS = map[string]interface{}{
4140
"SCHEME_SET": nil,
4241
"URL_SET": nil,

0 commit comments

Comments
 (0)