@@ -46,6 +46,7 @@ func Test_Lint(t *testing.T) {
4646
4747 t .Run ("lints file with no issues" , func (t * testing.T ) {
4848 t .Parallel ()
49+
4950 state := setupMockState (t )
5051
5152 results , err := lintFiles (state , false , "NoError.cdc" )
@@ -67,6 +68,7 @@ func Test_Lint(t *testing.T) {
6768
6869 t .Run ("lints file with import" , func (t * testing.T ) {
6970 t .Parallel ()
71+
7072 state := setupMockState (t )
7173
7274 results , err := lintFiles (state , false , "foo/WithImports.cdc" )
@@ -89,6 +91,7 @@ func Test_Lint(t *testing.T) {
8991
9092 t .Run ("lints multiple files" , func (t * testing.T ) {
9193 t .Parallel ()
94+
9295 state := setupMockState (t )
9396
9497 results , err := lintFiles (state , false , "NoError.cdc" , "foo/WithImports.cdc" )
@@ -114,6 +117,7 @@ func Test_Lint(t *testing.T) {
114117
115118 t .Run ("lints file with warning" , func (t * testing.T ) {
116119 t .Parallel ()
120+
117121 state := setupMockState (t )
118122
119123 results , err := lintFiles (state , false , "LintWarning.cdc" )
@@ -159,6 +163,7 @@ func Test_Lint(t *testing.T) {
159163
160164 t .Run ("lints file with error" , func (t * testing.T ) {
161165 t .Parallel ()
166+
162167 state := setupMockState (t )
163168
164169 results , err := lintFiles (state , false , "LintError.cdc" )
@@ -200,6 +205,7 @@ func Test_Lint(t *testing.T) {
200205
201206 t .Run ("generates synthetic replacement for replacement category diagnostics" , func (t * testing.T ) {
202207 t .Parallel ()
208+
203209 state := setupMockState (t )
204210
205211 results , err := lintFiles (state , false , "ReplacementHint.cdc" )
@@ -226,6 +232,7 @@ func Test_Lint(t *testing.T) {
226232
227233 t .Run ("linter resolves imports from flowkit state" , func (t * testing.T ) {
228234 t .Parallel ()
235+
229236 state := setupMockState (t )
230237
231238 results , err := lintFiles (state , false , "WithFlowkitImport.cdc" )
@@ -247,6 +254,7 @@ func Test_Lint(t *testing.T) {
247254
248255 t .Run ("resolves stdlib imports contracts" , func (t * testing.T ) {
249256 t .Parallel ()
257+
250258 state := setupMockState (t )
251259
252260 results , err := lintFiles (state , false , "StdlibImportsContract.cdc" )
@@ -280,6 +288,7 @@ func Test_Lint(t *testing.T) {
280288
281289 t .Run ("resolves stdlib imports transactions" , func (t * testing.T ) {
282290 t .Parallel ()
291+
283292 state := setupMockState (t )
284293
285294 results , err := lintFiles (state , false , "StdlibImportsTransaction.cdc" )
@@ -313,6 +322,7 @@ func Test_Lint(t *testing.T) {
313322
314323 t .Run ("resolves stdlib imports scripts" , func (t * testing.T ) {
315324 t .Parallel ()
325+
316326 state := setupMockState (t )
317327
318328 results , err := lintFiles (state , false , "StdlibImportsScript.cdc" )
@@ -322,8 +332,18 @@ func Test_Lint(t *testing.T) {
322332 & lintResult {
323333 Results : []fileResult {
324334 {
325- FilePath : "StdlibImportsScript.cdc" ,
326- Diagnostics : []analysis.Diagnostic {},
335+ FilePath : "StdlibImportsScript.cdc" ,
336+ Diagnostics : []analysis.Diagnostic {
337+ {
338+ Location : common .StringLocation ("StdlibImportsScript.cdc" ),
339+ Category : "security" ,
340+ Message : "hardcoded address detected — consider using named address imports for portability" ,
341+ Range : ast.Range {
342+ StartPos : ast.Position {Offset : 109 , Line : 5 , Column : 37 },
343+ EndPos : ast.Position {Offset : 112 , Line : 5 , Column : 40 },
344+ },
345+ },
346+ },
327347 },
328348 },
329349 exitCode : 0 ,
@@ -334,6 +354,7 @@ func Test_Lint(t *testing.T) {
334354
335355 t .Run ("resolves stdlib imports Crypto" , func (t * testing.T ) {
336356 t .Parallel ()
357+
337358 state := setupMockState (t )
338359
339360 results , err := lintFiles (state , false , "StdlibImportsCrypto.cdc" )
@@ -355,6 +376,7 @@ func Test_Lint(t *testing.T) {
355376
356377 t .Run ("resolves nested imports when contract imported by name" , func (t * testing.T ) {
357378 t .Parallel ()
379+
358380 state := setupMockState (t )
359381
360382 results , err := lintFiles (state , false , "TransactionImportingContractWithNestedImports.cdc" )
@@ -376,6 +398,7 @@ func Test_Lint(t *testing.T) {
376398
377399 t .Run ("allows access(account) when contracts on same account" , func (t * testing.T ) {
378400 t .Parallel ()
401+
379402 state := setupMockStateWithAccountAccess (t )
380403
381404 results , err := lintFiles (state , false , "ContractA.cdc" )
@@ -398,6 +421,7 @@ func Test_Lint(t *testing.T) {
398421
399422 t .Run ("denies access(account) when contracts on different accounts" , func (t * testing.T ) {
400423 t .Parallel ()
424+
401425 state := setupMockStateWithAccountAccess (t )
402426
403427 results , err := lintFiles (state , false , "ContractC.cdc" )
@@ -413,6 +437,7 @@ func Test_Lint(t *testing.T) {
413437
414438 t .Run ("allows access(account) when dependencies on same account (peak-money repro)" , func (t * testing.T ) {
415439 t .Parallel ()
440+
416441 state := setupMockStateWithDependencies (t )
417442
418443 results , err := lintFiles (state , false , "imports/testaddr/DepA.cdc" )
@@ -435,6 +460,7 @@ func Test_Lint(t *testing.T) {
435460
436461 t .Run ("allows access(account) when dependencies have Source but no Aliases" , func (t * testing.T ) {
437462 t .Parallel ()
463+
438464 state := setupMockStateWithSourceOnly (t )
439465
440466 // Verify that AddDependencyAsContract automatically adds Source to Aliases
@@ -561,11 +587,11 @@ func setupMockState(t *testing.T) *flowkit.State {
561587 _ = afero .WriteFile (mockFs , "Helper.cdc" , []byte (`
562588 access(all) contract Helper {
563589 access(all) let name: String
564-
590+
565591 init() {
566592 self.name = "Helper"
567593 }
568-
594+
569595 access(all) fun greet(): String {
570596 return "Hello from ".concat(self.name)
571597 }
@@ -574,7 +600,7 @@ func setupMockState(t *testing.T) *flowkit.State {
574600
575601 _ = afero .WriteFile (mockFs , "ContractWithNestedImports.cdc" , []byte (`
576602 import Helper from "./Helper.cdc"
577-
603+
578604 access(all) contract ContractWithNestedImports {
579605 access(all) fun test(): String {
580606 return Helper.greet()
@@ -585,7 +611,7 @@ func setupMockState(t *testing.T) *flowkit.State {
585611
586612 _ = afero .WriteFile (mockFs , "TransactionImportingContractWithNestedImports.cdc" , []byte (`
587613 import ContractWithNestedImports from "ContractWithNestedImports"
588-
614+
589615 transaction() {
590616 prepare(signer: auth(Storage) &Account) {
591617 log(ContractWithNestedImports.test())
@@ -631,7 +657,7 @@ func setupMockStateWithAccountAccess(t *testing.T) *flowkit.State {
631657 // ContractA imports and calls ContractB's account function - should work (same account)
632658 _ = afero .WriteFile (mockFs , "ContractA.cdc" , []byte (`
633659 import ContractB from "ContractB"
634-
660+
635661 access(all) contract ContractA {
636662 access(all) fun callB() {
637663 ContractB.accountOnlyFunction()
@@ -643,7 +669,7 @@ func setupMockStateWithAccountAccess(t *testing.T) *flowkit.State {
643669 // ContractC imports and calls ContractB's account function - should fail (different account)
644670 _ = afero .WriteFile (mockFs , "ContractC.cdc" , []byte (`
645671 import ContractB from "ContractB"
646-
672+
647673 access(all) contract ContractC {
648674 access(all) fun callB() {
649675 ContractB.accountOnlyFunction()
@@ -718,7 +744,7 @@ func setupMockStateWithDependencies(t *testing.T) *flowkit.State {
718744 // DepA imports and calls DepB's account function (like FlowEVMBridgeConfig)
719745 _ = afero .WriteFile (mockFs , "imports/testaddr/DepA.cdc" , []byte (`
720746 import DepB from "DepB"
721-
747+
722748 access(all) contract DepA {
723749 access(all) fun callDepB(forType: Type) {
724750 DepB.pauseConfig(forType: forType)
@@ -817,7 +843,7 @@ func setupMockStateWithSourceOnly(t *testing.T) *flowkit.State {
817843 // SourceA imports and calls SourceB's account function
818844 _ = afero .WriteFile (mockFs , "imports/testaddr/SourceA.cdc" , []byte (`
819845 import SourceB from "SourceB"
820-
846+
821847 access(all) contract SourceA {
822848 access(all) fun callSourceB() {
823849 SourceB.sourceOnlyFunction()
0 commit comments