Skip to content

Commit

Permalink
ci: add golangci lint (yeqown#73)
Browse files Browse the repository at this point in the history
* ci: add golangci lint and fix lint error
  • Loading branch information
yeqown authored Nov 9, 2022
1 parent 412857d commit f4e69cd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,30 @@ on:
branches: [ main ]

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.48

build:
name: build-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.18.0-beta2'
go-version: 1.19.2
stable: false

- name: Build
Expand Down
2 changes: 1 addition & 1 deletion encoder_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func WithErrorCorrectionLevel(ecLevel ecLevel) EncodeOption {
// WithVersion sets the version of target QR code.
func WithVersion(version int) EncodeOption {
return newFnEncodingOption(func(option *encodingOption) {
if version < 1 || version > 40 {
if version < 1 || version > _VERSION_COUNT {
return
}

Expand Down
1 change: 0 additions & 1 deletion matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func (m *Matrix) iter(dir iterDirection, visitFn func(x int, y int, v qrvalue))
visitFn(w, h, m.mat[w][h])
}
}
return
}

// Row return a row of matrix, cur should be y dimension.
Expand Down
32 changes: 16 additions & 16 deletions matrix_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,41 @@ func (v QRValue) IsSet() bool {
type qrvalue uint8

var (
// QRValue_INIT_V0 represents the value 0
QRValue_INIT_V0 = qrvalue(QRType_INIT | 0)
// QRValue_INIT_V0 represents the value 0 qrvalue(QRType_INIT | 0)
QRValue_INIT_V0 = qrvalue(QRType_INIT)

// QRValue_DATA_V0 represents the block has been set to false
QRValue_DATA_V0 = qrvalue(QRType_DATA | 0)
// QRValue_DATA_V0 represents the block has been set to false qrvalue(QRType_DATA | 0)
QRValue_DATA_V0 = qrvalue(QRType_DATA)
// QRValue_DATA_V1 represents the block has been set to TRUE
QRValue_DATA_V1 = qrvalue(QRType_DATA | 1)

// QRValue_VERSION_V0 represents the block has been set to false
QRValue_VERSION_V0 = qrvalue(QRType_VERSION | 0)
// QRValue_VERSION_V0 represents the block has been set to false qrvalue(QRType_VERSION | 0)
QRValue_VERSION_V0 = qrvalue(QRType_VERSION)
// QRValue_VERSION_V1 represents the block has been set to TRUE
QRValue_VERSION_V1 = qrvalue(QRType_VERSION | 1)

// QRValue_FORMAT_V0 represents the block has been set to false
QRValue_FORMAT_V0 = qrvalue(QRType_FORMAT | 0)
// QRValue_FORMAT_V0 represents the block has been set to false qrvalue(QRType_FORMAT | 0)
QRValue_FORMAT_V0 = qrvalue(QRType_FORMAT)
// QRValue_FORMAT_V1 represents the block has been set to TRUE
QRValue_FORMAT_V1 = qrvalue(QRType_FORMAT | 1)

// QRValue_FINDER_V0 represents the block has been set to false
QRValue_FINDER_V0 = qrvalue(QRType_FINDER | 0)
// QRValue_FINDER_V0 represents the block has been set to false qrvalue(QRType_FINDER | 0)
QRValue_FINDER_V0 = qrvalue(QRType_FINDER)
// QRValue_FINDER_V1 represents the block has been set to TRUE
QRValue_FINDER_V1 = qrvalue(QRType_FINDER | 1)

// QRValue_DARK_V0 represents the block has been set to false
QRValue_DARK_V0 = qrvalue(QRType_DARK | 0)
// QRValue_DARK_V0 represents the block has been set to false qrvalue(QRType_DARK | 0)
QRValue_DARK_V0 = qrvalue(QRType_DARK)
// QRValue_DARK_V1 represents the block has been set to TRUE
QRValue_DARK_V1 = qrvalue(QRType_DARK | 1)

// QRValue_SPLITTER_V0 represents the block has been set to false
QRValue_SPLITTER_V0 = qrvalue(QRType_SPLITTER | 0)
// QRValue_SPLITTER_V0 represents the block has been set to false qrvalue(QRType_SPLITTER | 0)
QRValue_SPLITTER_V0 = qrvalue(QRType_SPLITTER)
// QRValue_SPLITTER_V1 represents the block has been set to TRUE
QRValue_SPLITTER_V1 = qrvalue(QRType_SPLITTER | 1)

// QRValue_TIMING_V0 represents the block has been set to false
QRValue_TIMING_V0 = qrvalue(QRType_TIMING | 0)
// QRValue_TIMING_V0 represents the block has been set to false qrvalue(QRType_TIMING | 0)
QRValue_TIMING_V0 = qrvalue(QRType_TIMING)
// QRValue_TIMING_V1 represents the block has been set to TRUE
QRValue_TIMING_V1 = qrvalue(QRType_TIMING | 1)
)
Expand Down
5 changes: 2 additions & 3 deletions qrcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ func reserveVersionBlock(m *Matrix, dimension int) {

// fillDataBinary fill q.dataBSet binary stream into q.mat.
// References:
// * http://www.thonky.com/qr-code-tutorial/module-placement-matrix#Place-the-Data-Bits
//
// - http://www.thonky.com/qr-code-tutorial/module-placement-matrix#Place-the-Data-Bits
func (q *QRCode) fillDataBinary(m *Matrix, dimension int) {
var (
// x always move from right, left right loop (2 rows), y move upward, downward, upward loop
Expand Down Expand Up @@ -551,7 +550,7 @@ func (q *QRCode) fillDataBinary(m *Matrix, dimension int) {
x = x - 1
}
upForward = !upForward
state, err = m.at(x, y) // renew state qrbool after turn around writing direction.
state, _ = m.at(x, y) // renew state qrbool after turn around writing direction.
}
}

Expand Down

0 comments on commit f4e69cd

Please sign in to comment.