Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .custom-gcl.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v1.62.0
version: v2.1.6
plugins:
- module: "github.com/google/go-github/v68/tools/sliceofpointers"
path: ./tools/sliceofpointers
237 changes: 121 additions & 116 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,147 +1,152 @@
version: "2"
run:
build-tags:
- integration
timeout: 10m
linters:
enable:
- canonicalheader
- copyloopvar
- dogsled
- dupl
- gci
- gocritic
- godot
- gofmt
- goheader
- goimports
- gosec
- misspell
- nakedret
- paralleltest
- perfsprint
- revive
- sliceofpointers
- stylecheck
- staticcheck
- tparallel
- unconvert
- unparam
- whitespace
linters-settings:
custom:
sliceofpointers:
type: module
description: Reports usage of []*string and slices of structs without pointers.
original-url: github.com/google/go-github/v68/tools/sliceofpointers
gocritic:
disable-all: true
enabled-checks:
- commentedOutCode
- commentFormatting
goheader:
values:
regexp:
CopyrightDate: "Copyright \\d{4} "
template: |-
{{CopyrightDate}}The go-github AUTHORS. All rights reserved.
settings:
gocritic:
disable-all: true
enabled-checks:
- commentedOutCode
- commentFormatting
goheader:
values:
regexp:
CopyrightDate: 'Copyright \d{4} '
template: |-
{{CopyrightDate}}The go-github AUTHORS. All rights reserved.

Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
gosec:
excludes:
# duplicates errcheck
- G104
# int(os.Stdin.Fd())
- G115
misspell:
locale: US
ignore-words:
- "analyses" # returned by the GitHub API
- "cancelled" # returned by the GitHub API
# extra words from https://go.dev//wiki/Spelling
extra-words:
- typo: "marshall"
correction: "marshal"
- typo: "marshalled"
correction: "marshaled"
- typo: "marshalling"
correction: "marshaling"
- typo: "unmarshall"
correction: "unmarshal"
- typo: "unmarshalling"
correction: "unmarshaling"
- typo: "unmarshalled"
correction: "unmarshaled"
- typo: "unmarshalling"
correction: "unmarshaling"
perfsprint:
errorf: true
strconcat: false
revive:
# Set below 0.8 to enable error-strings rule.
confidence: 0.6
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
gosec:
excludes:
# duplicates errcheck
- G104
# int(os.Stdin.Fd())
- G115
misspell:
locale: US
# extra words from https://go.dev//wiki/Spelling
extra-words:
- typo: marshall
correction: marshal
- typo: marshalled
correction: marshaled
- typo: marshalling
correction: marshaling
- typo: unmarshall
correction: unmarshal
- typo: unmarshalling
correction: unmarshaling
- typo: unmarshalled
correction: unmarshaled
- typo: unmarshalling
correction: unmarshaling
ignore-rules:
- analyses # returned by the GitHub API
- cancelled # returned by the GitHub API
perfsprint:
errorf: true
strconcat: false
revive:
# Set below 0.8 to enable error-strings rule.
confidence: 0.6
rules:
- name: blank-imports
- name: bool-literal-in-expr
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: early-return
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: filename-format
arguments:
- ^[_a-z][_a-z0-9]*.go$
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unexported-naming
- name: unexported-return
- name: unreachable-code
- name: use-any
- name: var-declaration
- name: var-naming
staticcheck:
checks:
- "all"
- "-QF1008" # allow embedded field in selector
custom:
sliceofpointers:
type: module
description: Reports usage of []*string and slices of structs without pointers.
original-url: github.com/google/go-github/v68/tools/sliceofpointers
exclusions:
rules:
- name: blank-imports
- name: bool-literal-in-expr
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: early-return
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: filename-format
arguments:
- "^[_a-z][_a-z0-9]*.go$"
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unexported-naming
- name: unexported-return
- name: unreachable-code
- name: use-any
- name: var-declaration
- name: var-naming
issues:
exclude-use-default: false
exclude-rules:
- linters:
- dupl
- unparam
- gosec
- dogsled
path: _test\.go
- linters:
- dogsled
- dupl
- gosec
- unparam
path: _test\.go

# We need to pass nil Context in order to test DoBare erroring on nil ctx.
- linters: [staticcheck]
text: "SA1012: do not pass a nil Context"
path: _test\.go
# We need to pass nil Context in order to test DoBare erroring on nil ctx.
- linters: [staticcheck]
path: _test\.go
text: 'SA1012: do not pass a nil Context'

# We need to use sha1 for validating signatures
- linters: [gosec]
text: "G505: Blocklisted import crypto/sha1: weak cryptographic primitive"
# We need to use sha1 for validating signatures
- linters: [gosec]
text: 'G505: Blocklisted import crypto/sha1: weak cryptographic primitive'

# This is adapted from golangci-lint's default exclusions. It disables linting for error checks on
# os.RemoveAll, fmt.Fprint*, fmt.Scanf, and any function ending in "Close".
- linters: [errcheck]
text: Error return value of .(.*Close|fmt\.Fprint.*|fmt\.Scanf|os\.Remove(All)?). is not checked
# This is adapted from golangci-lint's default exclusions. It disables linting for error checks on
# os.RemoveAll, fmt.Fprint*, fmt.Scanf, and any function ending in "Close".
- linters: [errcheck]
text: Error return value of .(.*Close|fmt\.Fprint.*|fmt\.Scanf|os\.Remove(All)?). is not checked

# We don't care about file inclusion via variable in examples or internal tools.
- linters: [gosec]
text: "G304: Potential file inclusion via variable"
path: '^(example|tools)\/'
# We don't care about file inclusion via variable in examples or internal tools.
- linters: [gosec]
path: ^(example|tools)\/
text: 'G304: Potential file inclusion via variable'

# We don't run parallel integration tests
- linters: [paralleltest, tparallel]
path: "^test/integration"
# We don't run parallel integration tests
- linters: [paralleltest, tparallel]
path: ^test/integration

# Because fmt.Sprint(reset.Unix())) is more readable than strconv.FormatInt(reset.Unix(), 10).
- linters: [perfsprint]
text: "fmt.Sprint.* can be replaced with faster strconv.FormatInt"
# Because fmt.Sprint(reset.Unix())) is more readable than strconv.FormatInt(reset.Unix(), 10).
- linters: [perfsprint]
text: fmt.Sprint.* can be replaced with faster strconv.FormatInt
formatters:
enable:
- gci
- gofmt
- goimports
10 changes: 5 additions & 5 deletions github/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,20 @@ func (s *SearchService) search(ctx context.Context, searchType string, parameter
return nil, err
}
var acceptHeaders []string
switch {
case searchType == "commits":
switch searchType {
case "commits":
// Accept header for search commits preview endpoint
// TODO: remove custom Accept header when this API fully launches.
acceptHeaders = append(acceptHeaders, mediaTypeCommitSearchPreview)
case searchType == "topics":
case "topics":
// Accept header for search repositories based on topics preview endpoint
// TODO: remove custom Accept header when this API fully launches.
acceptHeaders = append(acceptHeaders, mediaTypeTopicsPreview)
case searchType == "repositories":
case "repositories":
// Accept header for search repositories based on topics preview endpoint
// TODO: remove custom Accept header when this API fully launches.
acceptHeaders = append(acceptHeaders, mediaTypeTopicsPreview)
case searchType == "issues":
case "issues":
// Accept header for search issues based on reactions preview endpoint
// TODO: remove custom Accept header when this API fully launches.
acceptHeaders = append(acceptHeaders, mediaTypeReactionsPreview)
Expand Down
11 changes: 3 additions & 8 deletions script/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -e

GOLANGCI_LINT_VERSION="1.63.4"
GOLANGCI_LINT_VERSION="2.1.6"

CDPATH="" cd -- "$(dirname -- "$0")/.."
BIN="$(pwd -P)"/bin
Expand All @@ -21,7 +21,7 @@ fail() {

# install golangci-lint and custom-gcl in ./bin if they don't exist with the correct version
if ! "$BIN"/custom-gcl --version 2> /dev/null | grep -q "$GOLANGCI_LINT_VERSION"; then
GOBIN="$BIN" go install "github.com/golangci/golangci-lint/cmd/golangci-lint@v$GOLANGCI_LINT_VERSION"
GOBIN="$BIN" go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v$GOLANGCI_LINT_VERSION"
"$BIN"/golangci-lint custom && mv ./custom-gcl "$BIN"
fi

Expand All @@ -32,12 +32,7 @@ for dir in $MOD_DIRS; do
echo linting "$dir"
(
cd "$dir"
# github actions output when running in an action
if [ -n "$GITHUB_ACTIONS" ]; then
"$BIN"/custom-gcl run --path-prefix "$dir" --out-format colored-line-number
else
"$BIN"/custom-gcl run --path-prefix "$dir"
fi
"$BIN"/custom-gcl run --path-prefix "$dir"
) || fail "failed linting $dir"
done

Expand Down
Loading