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 .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
args: --enable-only=staticcheck
args: --enable-only=staticcheck,unused # this is temporary until we can fix the other issues
18 changes: 18 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

version: "2"
issues:
max-issues-per-linter: 0 # show all issues found by each linter
max-same-issues: 0 # don't ignore same issues
linters:
exclusions:
rules:
- path: hclsyntax/scan_string_lit.go # generated file, ignore errors
linters:
- unused
- staticcheck
- path: hclsyntax/scan_tokens.go # generated file, ignore errors
linters:
- unused
- staticcheck
2 changes: 1 addition & 1 deletion ext/transform/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// Assert that deepWrapper implements Body
var deepWrapperIsBody hcl.Body = deepWrapper{}
var _ hcl.Body = deepWrapper{}

func TestDeep(t *testing.T) {

Expand Down
2 changes: 1 addition & 1 deletion gohcl/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ var victimBody hcl.Body

var exprType = reflect.TypeOf(&victimExpr).Elem()
var bodyType = reflect.TypeOf(&victimBody).Elem()
var blockType = reflect.TypeOf((*hcl.Block)(nil))

var attrType = reflect.TypeOf((*hcl.Attribute)(nil))
var attrsType = reflect.TypeOf(hcl.Attributes(nil))
12 changes: 9 additions & 3 deletions hclsyntax/scan_string_lit.go
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was regenerated by running go generate ./hclsyntax/generate.go and undoes changes made in 314d236.

Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
_lower := int(_keys)
var _mid int
_upper := int(_keys + _klen - 1)
for _upper >= _lower {
for {
if _upper < _lower {
break
}

_mid = _lower + ((_upper - _lower) >> 1)
switch {
Expand All @@ -194,7 +197,10 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
_lower := int(_keys)
var _mid int
_upper := int(_keys + (_klen << 1) - 2)
for _upper >= _lower {
for {
if _upper < _lower {
break
}

_mid = _lower + (((_upper - _lower) >> 1) & ^1)
switch {
Expand Down Expand Up @@ -290,7 +296,7 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
// be impossible (the scanner matches all bytes _somehow_) but we'll
// tolerate it and let the caller deal with it.
if cs < hclstrtok_first_final {
ret = append(ret, data[p:])
ret = append(ret, data[p:len(data)])
}

return ret
Expand Down
11 changes: 9 additions & 2 deletions hclsyntax/scan_tokens.go
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was regenerated by running go generate ./hclsyntax/generate.go and undoes changes in 314d236.

Original file line number Diff line number Diff line change
Expand Up @@ -4323,7 +4323,10 @@ func scanTokens(data []byte, filename string, start hcl.Pos, mode scanMode) []To
_lower := int(_keys)
var _mid int
_upper := int(_keys + _klen - 1)
for _upper >= _lower {
for {
if _upper < _lower {
break
}

_mid = _lower + ((_upper - _lower) >> 1)
switch {
Expand All @@ -4345,7 +4348,11 @@ func scanTokens(data []byte, filename string, start hcl.Pos, mode scanMode) []To
_lower := int(_keys)
var _mid int
_upper := int(_keys + (_klen << 1) - 2)
for _upper >= _lower {
for {
if _upper < _lower {
break
}

_mid = _lower + (((_upper - _lower) >> 1) & ^1)
switch {
case data[p] < _hcltok_trans_keys[_mid]:
Expand Down
2 changes: 1 addition & 1 deletion hclsyntax/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Body struct {
}

// Assert that *Body implements hcl.Body
var assertBodyImplBody hcl.Body = &Body{}
var _ hcl.Body = &Body{}

func (b *Body) walkChildNodes(w internalWalkFunc) {
w(b.Attributes)
Expand Down
7 changes: 4 additions & 3 deletions hcltest/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
"github.com/zclconf/go-cty/cty"
)

var mockBodyIsBody hcl.Body = mockBody{}
var mockExprLiteralIsExpr hcl.Expression = mockExprLiteral{}
var mockExprVariableIsExpr hcl.Expression = mockExprVariable("")
// Assert mocks are compatible with the interfaces they implement.
var _ hcl.Body = mockBody{}
var _ hcl.Expression = mockExprLiteral{}
var _ hcl.Expression = mockExprVariable("")

func TestMockBodyPartialContent(t *testing.T) {
tests := map[string]struct {
Expand Down
8 changes: 2 additions & 6 deletions hclwrite/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (f *File) Bytes() []byte {
type comments struct {
leafNode

parent *node
tokens Tokens
}

Expand All @@ -71,8 +70,7 @@ func (c *comments) BuildTokens(to Tokens) Tokens {
type identifier struct {
leafNode

parent *node
token *Token
token *Token
}

func newIdentifier(token *Token) *identifier {
Expand All @@ -92,8 +90,7 @@ func (i *identifier) hasName(name string) bool {
type number struct {
leafNode

parent *node
token *Token
token *Token
}

func newNumber(token *Token) *number {
Expand All @@ -109,7 +106,6 @@ func (n *number) BuildTokens(to Tokens) Tokens {
type quoted struct {
leafNode

parent *node
tokens Tokens
}

Expand Down
9 changes: 0 additions & 9 deletions json/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ func parseValue(p *peeker) (node, hcl.Diagnostics) {
}
}

func tokenCanStartValue(tok token) bool {
switch tok.Type {
case tokenBraceO, tokenBrackO, tokenNumber, tokenString, tokenKeyword:
return true
default:
return false
}
}

func parseObject(p *peeker) (node, hcl.Diagnostics) {
var diags hcl.Diagnostics

Expand Down
Loading