Skip to content

Commit

Permalink
unwrapped condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Aug 13, 2024
1 parent 86d5895 commit 5f7baa0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/linter/root_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,22 @@ func (r *rootChecker) checkFuncParam(p *ir.Parameter) {
}

func (r *rootChecker) CheckParamNullability(p *ir.Parameter) {
if param, ok := p.VariableType.(*ir.Name); ok {
if defValue, ok := p.DefaultValue.(*ir.ConstFetchExpr); ok {
if defValue.Constant.Value != "null" {
return
}
r.walker.Report(param, LevelWarning, "nullableType", "parameter with null default value should be explicitly nullable")
r.walker.addQuickFix("nullableType", r.quickfix.NullableType(param))
}
param, paramOk := p.VariableType.(*ir.Name)
if !paramOk {
return
}

defValue, defValueOk := p.DefaultValue.(*ir.ConstFetchExpr)
if !defValueOk {
return
}

if defValue.Constant.Value != "null" {
return
}

r.walker.Report(param, LevelWarning, "nullableType", "parameter with null default value should be explicitly nullable")
r.walker.addQuickFix("nullableType", r.quickfix.NullableType(param))
}

func (r *rootChecker) CheckTypeHintFunctionParam(p *ir.Parameter) {
Expand Down

0 comments on commit 5f7baa0

Please sign in to comment.