Skip to content

Commit

Permalink
Merge pull request #258 from onflow/auto-update-onflow-cadence-0ff20e…
Browse files Browse the repository at this point in the history
…15e7e1
  • Loading branch information
turbolent authored Dec 18, 2023
2 parents 5b04c6e + b39d90c commit 530d02b
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 549 deletions.
89 changes: 0 additions & 89 deletions lint/auth_account_parameter_analyzer.go

This file was deleted.

172 changes: 0 additions & 172 deletions lint/auth_account_parameter_analyzer_test.go

This file was deleted.

48 changes: 1 addition & 47 deletions lint/deprecated_member_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,9 @@ import (
"regexp"

"github.com/onflow/cadence/runtime/ast"
"github.com/onflow/cadence/runtime/sema"
"github.com/onflow/cadence/tools/analysis"
)

func memberReplacement(memberInfo sema.MemberInfo) string {
memberName := memberInfo.Member.Identifier.Identifier
switch memberInfo.AccessedType {
case sema.AuthAccountType:
switch memberName {
case sema.AuthAccountTypeAddPublicKeyFunctionName:
return "keys.add"

case sema.AuthAccountTypeRemovePublicKeyFunctionName:
return "keys.revoke"

case sema.AuthAccountTypeGetCapabilityFunctionName:
return "capabilities.get"

case sema.AuthAccountTypeLinkFunctionName:
return "capabilities.storage.issue"

case sema.AuthAccountTypeLinkAccountFunctionName:
return "capabilities.account.issue"

case sema.AuthAccountTypeUnlinkFunctionName:
return "capabilities.unpublish"
}
}

return ""
}

var docStringDeprecationWarningPattern = regexp.MustCompile(`(?i)[\t *_]*deprecated\b(?:[*_]*: (.*))?`)

func MemberIsDeprecated(docString string) bool {
Expand Down Expand Up @@ -87,7 +58,7 @@ var DeprecatedMemberAnalyzer = (func() *analysis.Analyzer {
return
}

memberInfo, _ := elaboration.MemberExpressionMemberInfo(memberExpression)
memberInfo, _ := elaboration.MemberExpressionMemberAccessInfo(memberExpression)
member := memberInfo.Member
if member == nil {
return
Expand All @@ -102,22 +73,6 @@ var DeprecatedMemberAnalyzer = (func() *analysis.Analyzer {

identifierRange := ast.NewRangeFromPositioned(nil, memberExpression.Identifier)

var suggestedFixes []analysis.SuggestedFix

replacement := memberReplacement(memberInfo)
if replacement != "" {
suggestedFix := analysis.SuggestedFix{
Message: "replace",
TextEdits: []analysis.TextEdit{
{
Replacement: replacement,
Range: identifierRange,
},
},
}
suggestedFixes = append(suggestedFixes, suggestedFix)
}

report(
analysis.Diagnostic{
Location: location,
Expand All @@ -129,7 +84,6 @@ var DeprecatedMemberAnalyzer = (func() *analysis.Analyzer {
memberName,
),
SecondaryMessage: docStringMatch[1],
SuggestedFixes: suggestedFixes,
},
)
},
Expand Down
11 changes: 7 additions & 4 deletions lint/deprecated_member_analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@ import (

func TestDeprecatedMemberAnalyzer(t *testing.T) {

// TODO: no more deprecated members
t.SkipNow()

t.Parallel()

diagnostics := testAnalyzers(t,
`
pub contract Test {
access(all) contract Test {
/// **DEPRECATED**
pub fun foo() {}
access(all) fun foo() {}
/// Deprecated: No good
pub fun bar() {}
access(all) fun bar() {}
pub fun test(account: AuthAccount) {
access(all) fun test(account: AuthAccount) {
account.addPublicKey([])
account.removePublicKey(0)
self.foo()
Expand Down
Loading

0 comments on commit 530d02b

Please sign in to comment.