Skip to content

Commit

Permalink
adjust to API changes of dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Dec 16, 2022
1 parent 7457cba commit 3c3ac9c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
6 changes: 3 additions & 3 deletions lint/deprecated_key_functions_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var DeprecatedKeyFunctionsAnalyzer = (func() *analysis.Analyzer {
return
}

memberInfo := elaboration.MemberExpressionMemberInfos[memberExpression]
memberInfo, _ := elaboration.MemberExpressionMemberInfo(memberExpression)
member := memberInfo.Member
if member == nil {
return
Expand All @@ -70,9 +70,9 @@ var DeprecatedKeyFunctionsAnalyzer = (func() *analysis.Analyzer {
var replacement string
functionName := member.Identifier.Identifier
switch functionName {
case sema.AuthAccountAddPublicKeyField:
case sema.AuthAccountTypeAddPublicKeyFunctionName:
replacement = "keys.add"
case sema.AuthAccountRemovePublicKeyField:
case sema.AuthAccountTypeRemovePublicKeyFunctionName:
replacement = "keys.revoke"
default:
return
Expand Down
24 changes: 18 additions & 6 deletions lint/number_function_argument_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,29 @@ var NumberFunctionArgumentAnalyzer = (func() *analysis.Analyzer {

switch expr := element.(type) {
case *ast.IntegerExpression:
argumentData, ok := elaboration.NumberConversionArgumentTypes[expr]
if !ok {
argumentData := elaboration.NumberConversionArgumentTypes(expr)
if argumentData.Type == nil {
return
}
diagnostic = suggestIntegerLiteralConversionReplacement(expr, location, argumentData.Type, argumentData.Range)
diagnostic = suggestIntegerLiteralConversionReplacement(
expr,
location,
argumentData.Type,
argumentData.Range,
)

case *ast.FixedPointExpression:
argumentData, ok := elaboration.NumberConversionArgumentTypes[expr]
if !ok {
argumentData := elaboration.NumberConversionArgumentTypes(expr)
if argumentData.Type == nil {
return
}
diagnostic = suggestFixedPointLiteralConversionReplacement(expr, location, argumentData.Type, argumentData.Range)
diagnostic = suggestFixedPointLiteralConversionReplacement(
expr,
location,
argumentData.Type,
argumentData.Range,
)

default:
return
}
Expand Down
13 changes: 9 additions & 4 deletions lint/redundant_cast_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer {
return
}

redundantType, ok := elaboration.StaticCastTypes[castingExpression]
if ok && isRedundantCast(castingExpression.Expression,
redundantType := elaboration.StaticCastTypes(castingExpression)
if redundantType.ExprActualType != nil && isRedundantCast(
castingExpression.Expression,
redundantType.ExprActualType,
redundantType.TargetType,
redundantType.ExpectedType,
Expand All @@ -278,8 +279,10 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer {
return
}

alwaysSucceedingTypes, ok := elaboration.RuntimeCastTypes[castingExpression]
if ok && sema.IsSubType(alwaysSucceedingTypes.Left, alwaysSucceedingTypes.Right) {
alwaysSucceedingTypes := elaboration.RuntimeCastTypes(castingExpression)
if alwaysSucceedingTypes.Left != nil &&
sema.IsSubType(alwaysSucceedingTypes.Left, alwaysSucceedingTypes.Right) {

switch castingExpression.Operation {
case ast.OperationFailableCast:
report(
Expand All @@ -293,6 +296,7 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer {
alwaysSucceedingTypes.Right),
},
)

case ast.OperationForceCast:
report(
analysis.Diagnostic{
Expand All @@ -305,6 +309,7 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer {
alwaysSucceedingTypes.Right),
},
)

default:
panic(errors.NewUnreachableError())
}
Expand Down
2 changes: 1 addition & 1 deletion lint/unnecessary_force_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ var UnnecessaryForceAnalyzer = (func() *analysis.Analyzer {
if !ok {
return
}
valueType := elaboration.ForceExpressionTypes[forceExpression]

valueType := elaboration.ForceExpressionType(forceExpression)
if valueType == nil {
return
}
Expand Down

0 comments on commit 3c3ac9c

Please sign in to comment.