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

Created an error value, in case the for loop fails with index not found. #206

Merged

Conversation

Skarlso
Copy link
Member

@Skarlso Skarlso commented Aug 30, 2019

No description provided.

@Skarlso Skarlso changed the title Created an error value, in case the for loop failes with index not fo… Created an error value, in case the for loop fails with index not found. Aug 31, 2019
@codecov-io
Copy link

codecov-io commented Aug 31, 2019

Codecov Report

Merging #206 into master will decrease coverage by 0.03%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #206      +/-   ##
==========================================
- Coverage    62.2%   62.17%   -0.04%     
==========================================
  Files          48       48              
  Lines        3934     3944      +10     
==========================================
+ Hits         2447     2452       +5     
- Misses       1082     1085       +3     
- Partials      405      407       +2
Impacted Files Coverage Δ
handlers/pipeline.go 55.06% <0%> (-0.69%) ⬇️
workers/pipeline/pipeline.go 92.12% <76.92%> (-1.95%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6e14be...c76b5e3. Read the comment docs.

ap.Lock()
defer ap.Unlock()

l := len(ap.Pipelines)
if index >= l || index+1 > l {
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
if index >= l || index+1 > l {
if index >= l || index < 0 {

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey. :)

So, yeah, I left out 0 that's a good call. However, I'll tell you why index+1 > l needs to be there. :D It's a mind bender so...

This is the line we are protecting:
ap.Pipelines = append(ap.Pipelines[:index], ap.Pipelines[index+1:]...)
if l == 0:
The first part of append will fail.
if l == 1 and index = 1:
The first part will work because slice postfix is not inclusive.
But the second part, the index+1 will fail because that one is inclusive. And 2 is not a valid index to look from.

@michelvocks
Copy link
Member

@Skarlso overall LGTM. Only these two issues

Skarlso and others added 2 commits September 2, 2019 10:19
Co-Authored-By: Michel Vocks <michelvocks@gmail.com>
@Skarlso Skarlso merged commit 7c0f920 into gaia-pipeline:master Sep 2, 2019
@Skarlso
Copy link
Member Author

Skarlso commented Sep 2, 2019

Closes #204.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants