Skip to content

Commit c5672f8

Browse files
author
Abhijeet V
committed
suppress and/or fix lint errors by unused
The majority of unused declarations were one of 3 types: - Global constants or sentinel variables. These were untouched becuse they serve as documentation and may become useful in the future. - Variable declarations to assert a struct implements an interface. These are compile time safety nets and were also ountouched. - Runtime function - Unused fields in structs. These were removed to reduce overall since they serve no purpose and at best increase memory consumption and at worst make such structs more confusing to the reader. There was also an undocumented private function that was removed. It was straightforward and can be reimplemented if need be.
1 parent b4e27ae commit c5672f8

File tree

9 files changed

+22
-7
lines changed

9 files changed

+22
-7
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ jobs:
102102
- name: Run golangci-lint
103103
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
104104
with:
105-
args: --enable-only=staticcheck
105+
args: --enable-only=staticcheck,unused # this is temporary until we can fix the other issues

ext/transform/transform_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
)
1515

1616
// Assert that deepWrapper implements Body
17+
//
18+
//nolint:unused
1719
var deepWrapperIsBody hcl.Body = deepWrapper{}
1820

1921
func TestDeep(t *testing.T) {

gohcl/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var victimBody hcl.Body
1414

1515
var exprType = reflect.TypeOf(&victimExpr).Elem()
1616
var bodyType = reflect.TypeOf(&victimBody).Elem()
17+
18+
//nolint:unused
1719
var blockType = reflect.TypeOf((*hcl.Block)(nil))
1820
var attrType = reflect.TypeOf((*hcl.Attribute)(nil))
1921
var attrsType = reflect.TypeOf(hcl.Attributes(nil))

hclsyntax/scan_string_lit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ var _hclstrtok_eof_actions []byte = []byte{
109109
3,
110110
}
111111

112+
//nolint:unused
112113
const hclstrtok_start int = 4
113114
const hclstrtok_first_final int = 4
115+
116+
//nolint:unused
114117
const hclstrtok_error int = 0
115118

116119
const hclstrtok_en_quoted int = 10

hclsyntax/scan_tokens.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4207,10 +4207,14 @@ var _hcltok_eof_trans []int16 = []int16{
42074207
1513, 1513, 1513, 1513, 1513, 1513, 1513,
42084208
}
42094209

4210+
//nolint:unused
42104211
const hcltok_start int = 1459
42114212
const hcltok_first_final int = 1459
4213+
4214+
//nolint:unused
42124215
const hcltok_error int = 0
42134216

4217+
//nolint:unused
42144218
const hcltok_en_stringTemplate int = 1510
42154219
const hcltok_en_heredocTemplate int = 1524
42164220
const hcltok_en_bareTemplate int = 1535

hclsyntax/structure.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ type Body struct {
4242
}
4343

4444
// Assert that *Body implements hcl.Body
45+
//
46+
//nolint:unused
4547
var assertBodyImplBody hcl.Body = &Body{}
4648

4749
func (b *Body) walkChildNodes(w internalWalkFunc) {

hcltest/mock_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ import (
1313
"github.com/zclconf/go-cty/cty"
1414
)
1515

16+
//nolint:unused
1617
var mockBodyIsBody hcl.Body = mockBody{}
18+
19+
//nolint:unused
1720
var mockExprLiteralIsExpr hcl.Expression = mockExprLiteral{}
21+
22+
//nolint:unused
1823
var mockExprVariableIsExpr hcl.Expression = mockExprVariable("")
1924

2025
func TestMockBodyPartialContent(t *testing.T) {

hclwrite/ast.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (f *File) Bytes() []byte {
5454
type comments struct {
5555
leafNode
5656

57-
parent *node
5857
tokens Tokens
5958
}
6059

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

74-
parent *node
75-
token *Token
73+
token *Token
7674
}
7775

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

95-
parent *node
96-
token *Token
93+
token *Token
9794
}
9895

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

112-
parent *node
113109
tokens Tokens
114110
}
115111

json/parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func parseValue(p *peeker) (node, hcl.Diagnostics) {
101101
}
102102
}
103103

104+
//nolint:unused
104105
func tokenCanStartValue(tok token) bool {
105106
switch tok.Type {
106107
case tokenBraceO, tokenBrackO, tokenNumber, tokenString, tokenKeyword:

0 commit comments

Comments
 (0)