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 #8 - Effort in string can be converted to integer minutes #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Compro-Prasad
Copy link
Contributor

@Compro-Prasad Compro-Prasad commented Mar 11, 2018

Added tests/CMakeLists.txt and tests/main.cxx

@Compro-Prasad Compro-Prasad force-pushed the fix/8 branch 3 times, most recently from 6fdb683 to 17af893 Compare March 15, 2018 07:23
Copy link
Member

@joesteeve joesteeve left a comment

Choose a reason for hiding this comment

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

This looks very complicated. I am thinking, probably we should reduce the feature requirement of this particular function. Lets discuss this on the ML.

src/util.cxx Outdated
NAMESPACE__THITTAM_UTIL__START


std::string getString(const std::string &s, unsigned &pos) {
Copy link
Member

Choose a reason for hiding this comment

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

  1. We use 'snake_case' for function and variable names. So, please keep with that consistently.
  2. See how we place curly braces in the start of the function, in other code. Please maintain the same for consistency.

src/util.cxx Outdated
bool sign = 0;

if (s[pos] == '-')
sign = true, pos++;
Copy link
Member

Choose a reason for hiding this comment

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

Even if a block (if/for/while/) is only one line, you should include curly braces.

src/util.cxx Outdated
bool sign = 0;

if (s[pos] == '-')
sign = true, pos++;
Copy link
Member

Choose a reason for hiding this comment

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

These should be two statements.

src/util.cxx Outdated
for (unsigned i = 0; i < effort.length(); ++i)
{

while (isspace(effort[i])) i++; // Skip space
Copy link
Member

Choose a reason for hiding this comment

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

You should NEVER do this. This is very tricky for readability. Its much better to just 'continue'. That way the control of the iteration is in one place, i..e the 'for'.

src/util.cxx Outdated
case 'd': // day
minutes += 60.0 * hours_per_day * currentNumber;
break;
case 'h': minutes += 60.0 * currentNumber; break;
Copy link
Member

Choose a reason for hiding this comment

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

One statement per line.

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.

2 participants