Skip to content

Commit ca09b60

Browse files
authored
Run various cleanup, not affecting the logic of the package (#43)
1 parent 4315d7d commit ca09b60

File tree

11 files changed

+80
-84
lines changed

11 files changed

+80
-84
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

.github/workflows/codeql-analysis.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ main ]
16+
branches: [main]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ main ]
19+
branches: [main]
2020
schedule:
21-
- cron: '35 16 * * 1'
21+
- cron: "35 16 * * 1"
2222

2323
jobs:
2424
analyze:
@@ -32,39 +32,39 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
language: [ 'go' ]
35+
language: ["go"]
3636
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3737
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3838

3939
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v3
40+
- name: Checkout repository
41+
uses: actions/checkout@v3
4242

43-
# Initializes the CodeQL tools for scanning.
44-
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v2
46-
with:
47-
languages: ${{ matrix.language }}
48-
# If you wish to specify custom queries, you can do so here or in a config file.
49-
# By default, queries listed here will override any specified in a config file.
50-
# Prefix the list here with "+" to use these queries and those in the config file.
51-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5252

53-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54-
# If this step fails, then you should remove it and run the build manually (see below)
55-
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v2
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v2
5757

58-
# ℹ️ Command-line programs to run using the OS shell.
59-
# 📚 https://git.io/JvXDl
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
6060

61-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62-
# and modify them (or add more) to build your code if your project
63-
# uses a compiled language
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
6464

65-
#- run: |
66-
# make bootstrap
67-
# make release
65+
#- run: |
66+
# make bootstrap
67+
# make release
6868

69-
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v2
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v2

.github/workflows/go.yml

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
11
name: Go
22
on: [push]
33
jobs:
4-
54
build:
65
name: Build
76
runs-on: ubuntu-latest
87
steps:
8+
- name: Set up Go 1.17
9+
uses: actions/setup-go@v1
10+
with:
11+
go-version: 1.17
12+
id: go
913

10-
- name: Set up Go 1.17
11-
uses: actions/setup-go@v1
12-
with:
13-
go-version: 1.17
14-
id: go
15-
16-
- name: Check out code into the Go module directory
17-
uses: actions/checkout@v1
14+
- name: Check out code into the Go module directory
15+
uses: actions/checkout@v1
1816

19-
- name: Get dependencies
20-
run: go get -v -t -d ./...
17+
- name: Get dependencies
18+
run: go get -v -t -d ./...
2119

22-
- name: Build
23-
run: go build -v .
20+
- name: Build
21+
run: go build -v .
2422

25-
- name: Test (race)
26-
run: go test -race -v -coverprofile=profile.cov -covermode=atomic ./...
23+
- name: Test (race)
24+
run: go test -race -v -coverprofile=profile.cov -covermode=atomic ./...
2725

28-
- name: Coverage
29-
uses: shogo82148/actions-goveralls@v1
30-
with:
31-
path-to-profile: profile.cov
26+
- name: Coverage
27+
uses: shogo82148/actions-goveralls@v1
28+
with:
29+
path-to-profile: profile.cov
3230

33-
- name: Install Linter
34-
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2
31+
- name: Install Linter
32+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.2
3533

36-
- name: Lint
37-
run: ./bin/golangci-lint run .
34+
- name: Lint
35+
run: ./bin/golangci-lint run .

.golangci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,10 @@ linters-settings:
6464
min-len: 10
6565
# minimal occurrences count to trigger, 3 by default
6666
min-occurrences: 3
67-
depguard:
68-
list-type: blacklist
69-
include-go-root: false
70-
packages:
71-
- github.com/satori/go.uuid
7267

7368
# packages-with-error-messages:
74-
# specify an error message to output when a blacklisted package is used
75-
# github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
69+
# specify an error message to output when a blacklisted package is used
70+
# github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
7671
misspell:
7772
# Correct spellings using locale preferences for US or UK.
7873
# Default is to use a neutral variety of English.
@@ -145,7 +140,7 @@ linters-settings:
145140
max-blank-identifiers: 2
146141

147142
whitespace:
148-
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
143+
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
149144
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
150145

151146
linters:
@@ -154,6 +149,8 @@ linters:
154149
- godot
155150
- nlreturn
156151

152+
- depguard
153+
157154
# These are apparently deprecated but still yell at you if you don't disable them
158155
- golint
159156
- scopelint
@@ -171,7 +168,6 @@ linters:
171168
- unused
172169
fast: false
173170

174-
175171
issues:
176172
# Excluding configuration per-path, per-linter, per-text and per-source
177173
exclude-rules:

core.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (a *Asserter) pathassertf(path, act, exp string) {
3838
a.tt.Errorf("actual JSON (%s) and expected JSON (%s) were of different types at '%s'", actType, expType, path)
3939
return
4040
}
41-
switch actType { // nolint:exhaustive // already know it's valid JSON and not null
41+
switch actType { //nolint:exhaustive // already know it's valid JSON and not null
4242
case jsonBoolean:
4343
actBool, _ := extractBoolean(act)
4444
expBool, _ := extractBoolean(exp)
@@ -63,7 +63,7 @@ func (a *Asserter) pathassertf(path, act, exp string) {
6363
}
6464

6565
func serialize(a interface{}) string {
66-
// nolint:errchkjson // Can be confident this won't return an error: the
66+
//nolint:errchkjson // Can be confident this won't return an error: the
6767
// input will be a nested part of valid JSON, thus valid JSON
6868
bytes, _ := json.Marshal(a)
6969
return string(bytes)

examples_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ func (p *printer) Errorf(format string, args ...interface{}) {
1313
}
1414

1515
// using the varible name 't' to mimic a *testing.T variable
16-
// nolint:gochecknoglobals // this is global to make the examples look like valid test code
16+
//
17+
//nolint:gochecknoglobals // this is global to make the examples look like valid test code
1718
var t *printer
1819

1920
func ExampleNew() {

exports.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ you only need one *jsonassert.Asseter per (sub)test.
6464
In most cases, this will look something like
6565
6666
ja := jsonassert.New(t)
67-
6867
*/
6968
func New(p Printer) *Asserter {
7069
// Initially this package was written without the assumption that the

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/kinbiko/jsonassert
22

3-
go 1.17
3+
go 1.19

helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func (*noopHelperTT) Helper() {
1818
// e.g. to verify where one potential candidate is matching or not.
1919
type deepEqualityPrinter struct{ count int }
2020

21-
func (p *deepEqualityPrinter) Errorf(msg string, args ...interface{}) { p.count++ }
22-
func (p *deepEqualityPrinter) Helper() { /* Intentional NOOP */ }
21+
func (p *deepEqualityPrinter) Errorf(_ string, _ ...interface{}) { p.count++ }
22+
func (p *deepEqualityPrinter) Helper() { /* Intentional NOOP */ }
2323

2424
func (a *Asserter) deepEqual(act, exp interface{}) bool {
2525
p := &deepEqualityPrinter{count: 0}

integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ type testCase struct {
460460

461461
func (tc *testCase) check(t *testing.T) {
462462
t.Helper()
463-
tp := &testPrinter{}
463+
tp := &testPrinter{messages: nil}
464464
jsonassert.New(tp).Assertf(tc.act, tc.exp)
465465

466466
if got := len(tp.messages); got != len(tc.msgs) {

number.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import (
66
)
77

88
// This is *probably* good enough. Can change this to be even smaller if necessary
9-
const minDiff = 0.000001
10-
const bitSize = 64
9+
const (
10+
minDiff = 0.000001
11+
bitSize = 64
12+
)
1113

1214
func (a *Asserter) checkNumber(path string, act, exp float64) {
1315
a.tt.Helper()

0 commit comments

Comments
 (0)