Skip to content

Commit fe3ed29

Browse files
committed
Fixed some linter warnings
1 parent d78e71e commit fe3ed29

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Diff for: arduino/cores/packagemanager/loader.go

+2
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ func convertUploadToolsToPluggableDiscovery(props *properties.Map) {
589589
props.Merge(propsToAdd)
590590
}
591591

592+
// LoadToolsFromPackageDir loads a set of tools from the given toolsPath. The tools will be loaded
593+
// in the given *Package.
592594
func (pm *PackageManager) LoadToolsFromPackageDir(targetPackage *cores.Package, toolsPath *paths.Path) []error {
593595
pm.Log.Infof("Loading tools from dir: %s", toolsPath)
594596

Diff for: arduino/sketch/profiles.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,15 @@ func parseNameAndVersion(in string) (string, string, bool) {
134134
return split[0][1], split[0][2], true
135135
}
136136

137+
// UnmarshalYAML decodes a ProfilePlatformReference from YAML source.
137138
func (p *ProfilePlatformReference) UnmarshalYAML(unmarshal func(interface{}) error) error {
138139
var data map[string]string
139140
if err := unmarshal(&data); err != nil {
140141
return err
141142
}
142-
if platformId, ok := data["platform"]; !ok {
143+
if platformID, ok := data["platform"]; !ok {
143144
return fmt.Errorf(tr("missing 'platform' directive"))
144-
} else if platformId, platformVersion, ok := parseNameAndVersion(platformId); !ok {
145+
} else if platformId, platformVersion, ok := parseNameAndVersion(platformID); !ok {
145146
return fmt.Errorf(tr("invalid 'platform' directive"))
146147
} else if c, err := semver.Parse(platformVersion); err != nil {
147148
return fmt.Errorf("%s: %w", tr("error parsing version constraints"), err)
@@ -154,11 +155,11 @@ func (p *ProfilePlatformReference) UnmarshalYAML(unmarshal func(interface{}) err
154155
}
155156

156157
if rawIndexURL, ok := data["platform_index_url"]; ok {
157-
if indexURL, err := url.Parse(rawIndexURL); err != nil {
158+
indexURL, err := url.Parse(rawIndexURL)
159+
if err != nil {
158160
return fmt.Errorf("%s: %w", tr("invlid platform index URL:"), err)
159-
} else {
160-
p.PlatformIndexURL = indexURL
161161
}
162+
p.PlatformIndexURL = indexURL
162163
}
163164
return nil
164165
}
@@ -169,6 +170,7 @@ type ProfileLibraryReference struct {
169170
Version *semver.Version
170171
}
171172

173+
// UnmarshalYAML decodes a ProfileLibraryReference from YAML source.
172174
func (l *ProfileLibraryReference) UnmarshalYAML(unmarshal func(interface{}) error) error {
173175
var data string
174176
if err := unmarshal(&data); err != nil {

Diff for: cli/instance/instance.go

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ func CreateAndInit() *rpc.Instance {
4141
return inst
4242
}
4343

44+
// CreateAndInitWithProfile return a new initialized instance using the given profile in the give sketch.
45+
// If Create fails the CLI prints an error and exits since to execute further operations a valid Instance is mandatory.
46+
// If Init returns errors they're printed only.
4447
func CreateAndInitWithProfile(profileName string, sketchPath *paths.Path) (*rpc.Instance, *rpc.Profile) {
4548
instance, err := Create()
4649
if err != nil {
@@ -73,6 +76,9 @@ func Init(instance *rpc.Instance) []error {
7376
return errs
7477
}
7578

79+
// InitWithProfile initializes instance by loading libraries and platforms specified in the given profile of the given sketch.
80+
// In case of loading failures return a list of errors for each platform or library that we failed to load.
81+
// Required Package and library indexes files are automatically downloaded.
7682
func InitWithProfile(instance *rpc.Instance, profileName string, sketchPath *paths.Path) (*rpc.Profile, []error) {
7783
errs := []error{}
7884

0 commit comments

Comments
 (0)