Skip to content

Commit 3a14601

Browse files
committed
Applied code review suggestion
1 parent ad5d941 commit 3a14601

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

commands/service_profile_lib_add.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func (s *arduinoCoreServerImpl) ProfileLibAdd(ctx context.Context, req *rpc.Prof
3535
if err != nil {
3636
return nil, err
3737
}
38-
projectFilePath := sk.GetProjectPath()
3938

4039
// If no profile is specified, try to use the default one
4140
profileName := sk.Project.DefaultProfile
@@ -129,8 +128,8 @@ func (s *arduinoCoreServerImpl) ProfileLibAdd(ctx context.Context, req *rpc.Prof
129128
return nil, &cmderrors.InvalidArgumentError{Message: "library must be specified"}
130129
}
131130

132-
err = projectFilePath.WriteFile([]byte(sk.Project.AsYaml()))
133-
if err != nil {
131+
projectFilePath := sk.GetProjectPath()
132+
if err = projectFilePath.WriteFile([]byte(sk.Project.AsYaml())); err != nil {
134133
return nil, err
135134
}
136135

commands/service_profile_lib_remove.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func (s *arduinoCoreServerImpl) ProfileLibRemove(ctx context.Context, req *rpc.P
3434
if err != nil {
3535
return nil, err
3636
}
37-
projectFilePath := sk.GetProjectPath()
3837

3938
// If no profile is specified, try to use the default one
4039
profileName := sk.Project.DefaultProfile
@@ -112,8 +111,8 @@ func (s *arduinoCoreServerImpl) ProfileLibRemove(ctx context.Context, req *rpc.P
112111
}
113112
}
114113

115-
err = projectFilePath.WriteFile([]byte(sk.Project.AsYaml()))
116-
if err != nil {
114+
projectFilePath := sk.GetProjectPath()
115+
if err = projectFilePath.WriteFile([]byte(sk.Project.AsYaml())); err != nil {
117116
return nil, &cmderrors.CantUpdateSketchError{Cause: err}
118117
}
119118

commands/service_profile_set_default.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ func (s *arduinoCoreServerImpl) ProfileSetDefault(ctx context.Context, req *rpc.
3535
if err != nil {
3636
return nil, err
3737
}
38-
projectFilePath := sk.GetProjectPath()
3938

4039
if _, err := sk.GetProfile(req.GetProfileName()); err != nil {
4140
return nil, err
4241
}
4342

4443
sk.Project.DefaultProfile = req.GetProfileName()
45-
err = projectFilePath.WriteFile([]byte(sk.Project.AsYaml()))
46-
if err != nil {
44+
projectFilePath := sk.GetProjectPath()
45+
if err = projectFilePath.WriteFile([]byte(sk.Project.AsYaml())); err != nil {
4746
return nil, err
4847
}
4948

0 commit comments

Comments
 (0)