Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix remaining linter warnings #766

Closed
wants to merge 1 commit into from
Closed

Conversation

bennyz
Copy link
Member

@bennyz bennyz commented Feb 26, 2024

No description provided.

@bennyz bennyz force-pushed the linter-sequel branch 2 times, most recently from c288364 to d71bae5 Compare February 26, 2024 10:32
Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 8.88889% with 41 lines in your changes are missing coverage. Please review.

Project coverage is 16.84%. Comparing base (a55e08e) to head (dc7cb7c).
Report is 219 commits behind head on main.

Files Patch % Lines
...volume-populator/populator-machinery/controller.go 0.00% 20 Missing ⚠️
...controller/provider/container/vsphere/collector.go 0.00% 13 Missing ⚠️
...ib-volume-populator/populator-machinery/metrics.go 25.00% 2 Missing and 1 partial ⚠️
pkg/controller/plan/adapter/ova/builder.go 50.00% 2 Missing ⚠️
cmd/openstack-populator/openstack-populator.go 0.00% 1 Missing ⚠️
pkg/controller/provider/web/base/utils.go 0.00% 1 Missing ⚠️
pkg/lib/inventory/model/field.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main     #766       +/-   ##
=========================================
+ Coverage      0   16.84%   +16.84%     
=========================================
  Files         0       88       +88     
  Lines         0    17896    +17896     
=========================================
+ Hits          0     3014     +3014     
- Misses        0    14638    +14638     
- Partials      0      244      +244     
Flag Coverage Δ
unittests 16.84% <8.88%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bennyz bennyz force-pushed the linter-sequel branch 3 times, most recently from cfff9be to b6fe103 Compare February 26, 2024 11:21
Signed-off-by: Benny Zlotnik <[email protected]>
Copy link

sonarcloud bot commented Feb 26, 2024

Quality Gate Passed Quality Gate passed

Issues
19 New issues

Measures
0 Security Hotspots
No data about Coverage
7.5% Duplication on New Code

See analysis details on SonarCloud


metrics.StartPrometheusEndpoint("8443", "", certsDirectory)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you change the port to 8443 on purpose?

@@ -490,7 +489,7 @@ func getResourceCapacity(capacity int64, units string) (int64, error) {
for i := range items {
item := strings.TrimSpace(items[i])
if i == 0 && len(item) > 0 && item != "byte" {
return 0, errors.New(fmt.Sprintf("units '%s' are invalid, only 'byte' is supported", units))
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, only 'byte' is supported", units))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, only 'byte' is supported", units))
return 0, fmt.Errorf("units '%s' are invalid, only 'byte' is supported", units)

@@ -502,15 +501,15 @@ func getResourceCapacity(capacity int64, units string) (int64, error) {
}
nums := strings.Split(item, "^")
if len(nums) != 2 {
return 0, errors.New(fmt.Sprintf("units '%s' are invalid, item is invalid: %s", units, item))
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, item is invalid: %s", units, item))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, item is invalid: %s", units, item))
return 0, fmt.Errorf("units '%s' are invalid, item is invalid: %s", units, item)

}
base, err := strconv.Atoi(nums[0])
if err != nil {
return 0, errors.New(fmt.Sprintf("units '%s' are invalid, base component is invalid: %s", units, item))
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, base component is invalid: %s", units, item))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, base component is invalid: %s", units, item))
return 0, fmt.Errorf("units '%s' are invalid, base component is invalid: %s", units, item)

}
pow, err := strconv.Atoi(nums[1])
if err != nil {
return 0, errors.New(fmt.Sprintf("units '%s' are invalid, pow component is invalid: %s", units, item))
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, pow component is invalid: %s", units, item))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0, fmt.Errorf(fmt.Sprintf("units '%s' are invalid, pow component is invalid: %s", units, item))
return 0, fmt.Errorf("units '%s' are invalid, pow component is invalid: %s", units, item)

err = tx.End()
if err != nil {
err = liberr.Wrap(err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really recommended to set the error that within a go-routine?...

@@ -356,7 +356,15 @@ func (r *Collector) getUpdates(ctx context.Context) error {
if err != nil {
return liberr.Wrap(err)
}
defer pc.Destroy(context.Background())
defer func() {
err = pc.Destroy(context.Background())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question here - wouldn't it make sense to use a new variable?

go r.manager.Start(ctx)

go func() {
err = r.manager.Start(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here?

@@ -1032,14 +1032,14 @@ func TestWatch(t *testing.T) {
for i := 0; i < N; i++ {
switch action {
case Created:
created = append(
_ = append(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we drop the _ = part?

created,
TestEvent{
action: action,
model: &TestObject{ID: i},
})
case Updated:
updated = append(
_ = append(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here?

@yaacov
Copy link
Member

yaacov commented Oct 27, 2024

@mnecas @bennyz hi,

With the changing code, this PR is getting more and more out of date without @bennyz in the team to check and update it
I think we should close this PR because of @bennyz capacity ATM, WDYT ?

@bennyz bennyz closed this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants