Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Feb 8, 2024
1 parent 0c589ca commit 235692a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lint/cadence_v1_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

type cadenceV1Analyzer struct {
pass *analysis.Pass
program *analysis.Program
elaboration *sema.Elaboration
report func(analysis.Diagnostic)
inspector *ast.Inspector
Expand Down Expand Up @@ -57,7 +57,7 @@ func init() {

func newCadenceV1Analyzer(pass *analysis.Pass) *cadenceV1Analyzer {
visitor := &cadenceV1Analyzer{
pass: pass,
program: pass.Program,
elaboration: pass.Program.Checker.Elaboration,
report: pass.Report,
inspector: pass.ResultOf[analysis.InspectorAnalyzer].(*ast.Inspector),
Expand Down Expand Up @@ -97,10 +97,10 @@ func (v *cadenceV1Analyzer) analyzeRemovedAccountMembers() {
case "save":
v.newDiagnostic(
identifier,
"This has been removed in Cadence 1.0 in favour of the new Storage API.",
"`save` has been replaced by the new Storage API.",
"C1.0-StorageAPI-Save",
"https://forum.flow.com/t/update-on-cadence-1-0/5197#account-access-got-improved-55",
).Report()
).WithSimpleReplacement("storage.save").Report()

// acct.linkAccount()
case "linkAccount":
Expand Down Expand Up @@ -136,7 +136,7 @@ func (v *cadenceV1Analyzer) analyzeRemovedAccountMembers() {
"`getCapability` has been replaced by the Capability Controller API.",
"C1.0-CapabilityAPI-GetCapability",
"https://forum.flow.com/t/update-on-cadence-1-0/5197#capability-controller-api-replaced-existing-linking-based-capability-api-82",
).Report()
).WithSimpleReplacement("capabilities.get").Report()

// acct.getLinkTarget()
case "getLinkTarget":
Expand Down Expand Up @@ -314,7 +314,7 @@ func (v *cadenceV1Analyzer) newDiagnostic(
docURL string,
) *diagnostic {
return newDiagnostic(
v.pass.Program.Location,
v.program.Location,
v.report,
fmt.Sprintf("[Cadence 1.0] %s", message),
ast.NewRangeFromPositioned(nil, position),
Expand Down
26 changes: 24 additions & 2 deletions lint/cadence_v1_analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,32 @@ func TestCadenceV1Analyzer(t *testing.T) {
Location: testLocation,
Severity: analysis.SeverityError,
Category: lint.CadenceV1Category,
Message: "[Cadence 1.0] This has been removed in Cadence 1.0 in favour of the new Storage API.",
Message: "[Cadence 1.0] `save` has been replaced by the new Storage API.",
Code: "C1.0-StorageAPI-Save",
DocURL: "https://forum.flow.com/t/update-on-cadence-1-0/5197#account-access-got-improved-55",
SuggestedFixes: []analysis.SuggestedFix{},
SuggestedFixes: []analysis.SuggestedFix{
{
Message: "Replace with `storage.save`",
TextEdits: []ast.TextEdit{
{
Replacement: "storage.save",
Insertion: "",
Range: ast.Range{
StartPos: ast.Position{
Offset: 63,
Line: 4,
Column: 18,
},
EndPos: ast.Position{
Offset: 66,
Line: 4,
Column: 21,
},
},
},
},
},
},
Range: ast.Range{
StartPos: ast.Position{
Offset: 63,
Expand Down

0 comments on commit 235692a

Please sign in to comment.