Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If that's the intended behaviour (having those boundaries and those results), how can you ever confirm that behaviour without checking them all?


You could have one check such as

  if(percentage < 0 or percentage > 1) 
  {
      // Throw error here
  }
Also the checks in the if statements in the linked code are redundant since they simply disregard the previous check, they could simply check if percentage < x instead of checking it's within a range sincs the previous check already proved percentage to be > x - 1/10.

To be fair though, this is the kind of code where "if it's stupid and it works, it's not stupid" applies perfectly. While I would make these changes if I had to approve a PR I wouldn't change this in a live codebase just for refactoring purposes, specially because there are better ways to show progress to a user than using Unicode characters, which I think is the real smell here.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: