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

Failed to detect when body of function > 20 lines #20

Closed
selena81792 opened this issue Oct 5, 2018 · 4 comments
Closed

Failed to detect when body of function > 20 lines #20

selena81792 opened this issue Oct 5, 2018 · 4 comments
Assignees
Labels

Comments

@selena81792
Copy link

selena81792 commented Oct 5, 2018

NormEZ did not warn about the length of this function, very sad

int	my_getnbr(char *str)
{
    int negative_multiplier;
    unsigned long long int storage;

    negative_multiplier = 1;
    storage = 0;
    while (*str && *str != '\0' && (*str == '+' || *str == '-')){
        if (*str == '-') negative_multiplier *= -1;
        str++;
    }
    while (*str && *str != '\0' && (*str >= '0' && *str <= '9')){
        if (storage > 214748364){
            return 0;
        }
        storage = storage*10 + *str-48;
        str++;
    }
    if (negative_multiplier == -1 && storage > 2147483648){
        return 0;
    } else if (negative_multiplier == 1 && storage > 2147483647){
        return 0;
    }
    storage *= negative_multiplier;
    return (storage);
}
@ronanboiteau
Copy link
Owner

ronanboiteau commented Oct 5, 2018

That's because you have to respect the L4 - Curly brackets article of the coding style in order for the line check to work.

As an example, the following:

while (*str && *str != '\0' && (*str == '+' || *str == '-')){
        [...]
    }

...should be:

while (*str && *str != '\0' && (*str == '+' || *str == '-'))
    {
        [...]
    }

Once you've fix this, the line check will work fine.

@ronanboiteau
Copy link
Owner

That's the downside of "regex parsing". Since I don't use a real parser, I have to base the check on something. For the line check, I used the opening and closing curly brackets, because I know that they're always supposed to be alone on their line.

@ronanboiteau ronanboiteau self-assigned this Oct 5, 2018
@selena81792
Copy link
Author

The rule of L4 has changed now, they want us to put all curly backets on the end of the line (except with functions)

New rule screenshot: https://i.imgur.com/NHKl7J4.png

This is a pity, because it sounds like there will be a lot of work to change the bot to meet the new rules now...

@Nafiros
Copy link

Nafiros commented Mar 6, 2020

this issues seems to be fixed...

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

No branches or pull requests

3 participants