Skip to content

Commit

Permalink
Merge pull request #1525 from Permify/refactor/improve-error-handling…
Browse files Browse the repository at this point in the history
…-optimize-var-declaration

refactor: improve error handling and optimize variable declaration
  • Loading branch information
tolgaOzen authored Aug 27, 2024
2 parents ff123a5 + 800e2c8 commit f7bea56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/attribute/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Attribute(attribute string) (*base.Attribute, error) {
wrapped = &base.BooleanValue{Data: boolVal}
case "boolean[]":
val := strings.Split(v[1], ",")
var ba = make([]bool, len(val))
ba := make([]bool, len(val))
for i, value := range val {
boolVal, err := strconv.ParseBool(value)
if err != nil {
Expand All @@ -73,7 +73,7 @@ func Attribute(attribute string) (*base.Attribute, error) {
case "string":
wrapped = &base.StringValue{Data: v[1]}
case "string[]":
var sa = strings.Split(v[1], ",")
sa := strings.Split(v[1], ",")
wrapped = &base.StringArrayValue{Data: sa}
case "double":
doubleVal, err := strconv.ParseFloat(v[1], 64)
Expand All @@ -83,7 +83,7 @@ func Attribute(attribute string) (*base.Attribute, error) {
wrapped = &base.DoubleValue{Data: doubleVal}
case "double[]":
val := strings.Split(v[1], ",")
var da = make([]float64, len(val))
da := make([]float64, len(val))
for i, value := range val {
doubleVal, err := strconv.ParseFloat(value, 64)
if err != nil {
Expand All @@ -100,7 +100,7 @@ func Attribute(attribute string) (*base.Attribute, error) {
wrapped = &base.IntegerValue{Data: int32(intVal)}
case "integer[]":
val := strings.Split(v[1], ",")
var ia = make([]int32, len(val))
ia := make([]int32, len(val))
for i, value := range val {
intVal, err := strconv.ParseInt(value, 10, 32)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/development/coverage/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func Run(shape file.Shape) SchemaCoverageInfo {

schemaCoverageInfo := SchemaCoverageInfo{}

var refs = make([]SchemaCoverage, len(definitions))
refs := make([]SchemaCoverage, len(definitions))
for i, en := range definitions {
refs[i] = references(en)
}
Expand Down Expand Up @@ -269,7 +269,7 @@ func relationships(en string, relationships []string) []string {

// attributes - Get attributes for a given entity
func attributes(en string, attributes []string) []string {
var attrs = make([]string, len(attributes))
attrs := make([]string, len(attributes))
for i, attr := range attributes {
a, err := attribute.Attribute(attr)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func determineSchemaType(input string) (Type, error) {

valid, err := isFilePath(input)
if err != nil {
return Inline, err
return Inline, nil
}
if valid {
return File, nil
Expand Down

0 comments on commit f7bea56

Please sign in to comment.