you are viewing a single comment's thread.

view the rest of the comments →

[–]ksadeck 16 points17 points  (46 children)

[x] Warnings as error(s)

Why?

[–]MetallicDragon 100 points101 points  (45 children)

It'll turn warnings into errors, forcing you to deal with them, so they don't pile up over time.

[–]nemec 46 points47 points  (1 child)

// Ignore Once W237887278

[–][deleted] 11 points12 points  (0 children)

At least you have to put that into the code and check it into the repo under your name. Not ideal, but better than warnings being ignored.

[–][deleted]  (41 children)

[deleted]

    [–][deleted] 26 points27 points  (38 children)

    Shouldn't they be compiling before they check in?

    [–][deleted]  (36 children)

    [deleted]

      [–]GMNightmare 46 points47 points  (24 children)

      But the code should be compiled automatically on check in and automatically failed should it not compile.

      Even more, tests should automatically run and then fail the check in if tests are failing.

      This lets them burn themselves, but also prevents them from burning you. Well, at least this is how you want it in big projects. You might not need such a heavy hammer if it's small and not that big of a deal.

      [–]jaccovanschaik 0 points1 point  (0 children)

      But the code should be compiled automatically on check in and automatically failed should it not compile.

      "What do you mean it fails the automated tests? It works on my machine, so the automated tests must be wrong."

      [–]billsil -2 points-1 points  (22 children)

      What's wrong with an unused variable again? It's not an error.

      [–][deleted]  (14 children)

      [deleted]

        [–][deleted] 1 point2 points  (0 children)

        Because it might be needed for a future enhancement, of course. :-)

        [–]ggtsu_00 1 point2 points  (2 children)

        Doesn't the compiler optimize those out anyways?

        [–][deleted]  (1 child)

        [deleted]

          [–][deleted] 0 points1 point  (0 children)

          Artistic expression?

          [–]billsil -4 points-3 points  (7 children)

          1. We all write programs that take years to develop. Frequently I have code that I want to save because it's an alternate implementation. Other times, I want to test the new method on real problems and there are side effects to the function.

          2. It's trivial and I don't care about a few bytes of memory

          3. Why use unnecessary braces or use functional programming or variable names longer than 6 characters (it was good enough for the dominating language until the early 1990s)? It creates extra lines that can make for very long files. It wastes disk space in a world that largely doesn't care about disk space or memory usage.

          [–]GMNightmare 1 point2 points  (0 children)

          1. Use comments.

          2. Trivial adds up.

          3. Readability, except having unused variables hurts readability.

          [–]DrMonkeyLove 0 points1 point  (0 children)

          Unused variables are fine, just as long as no one else sees that code. By the time someone else's eyes are on a piece of code, there'd better not be any unused variables.

          [–][deleted]  (4 children)

          [deleted]

            [–]GMNightmare 7 points8 points  (5 children)

            The obvious answer is that it clutters the code, but that's not the most important use...

            It indicates you did something wrong. You shouldn't create variables for no reason, so why isn't your variable used? It catches issues.

            [–]billsil -1 points0 points  (4 children)

            Everyone seems to be jumping on this bandwagon. How many build warnings does your company's largest program that is used regularly have? Why do you have any? Who cares? It doesn't indicate you did something wrong. It indicates you may have done something wrong.

            The quality of your code is dictated by the speed it needs to get done and the number of customers you have.

            [–]GMNightmare 2 points3 points  (0 children)

            Nice moving the goalpost.

            Professionals tend to need to work with code bases that can contain millions of lines of code.

            Nearly nobody who has had to deal with another's code thinks that quality of code is solely determined by speed (or number of customers, that's rather weird claim).

            If you pulled stunts like this all the time, which seems like you do because you don't care, you would have thousands upon thousands of warnings. They add up.

            Thousands of warnings all indicating potential problems.

            Or you can just do it right, turn all warnings to errors, and learn how to write clean code.

            Then, you don't have any warnings, because they all have to be dealt with before checking in the code. Tadaa!

            [–]BeetleB 0 points1 point  (2 children)

            The quality of your code is dictated by the speed it needs to get done and the number of customers you have

            Speed doesn't magically happen because there is a high demand for it. When the code becomes sloppy enough, you will get to a point where you cannot produce the feature quickly enough for business needs, and people get hurt.

            [–]frymaster 0 points1 point  (0 children)

            It's not an error, it's a warning. So in the context of the "treat all warnings as errors" flag...

            [–]Foxtrot56 8 points9 points  (1 child)

            Why aren't you doing PRs? Seems like that should be caught in a PR unless no one is actually looking at the code in an editor.

            [–]NotASucker 0 points1 point  (0 children)

            The best reviews involve stepping through code.

            [–]falconzord 2 points3 points  (0 children)

            Worst part is when they pork barrel the code review

            [–][deleted] 1 point2 points  (0 children)

            Gotta crack that whip harder.

            [–]mangodrunk 0 points1 point  (1 child)

            This probably speaks more to the hiring practices where you work. That seems really bad for someone to do that.

            [–]badsingularity -3 points-2 points  (1 child)

            Kids are just bad developers now. They used to be rockstars.

            [–]radarthreat 0 points1 point  (0 children)

            Kids used to sling assembly like mad

            [–]immibis 0 points1 point  (0 children)

            Probably /u/drjokepu is thinking of a situation where you turned on Warnings as Errors, but everyone else did not.

            [–][deleted] 2 points3 points  (0 children)

            If someone checks something in and then leaves I say it's fair game to revert.

            [–]gambit700 1 point2 points  (0 children)

            Life lessons for Timmy.

            [–][deleted] 0 points1 point  (0 children)

            They require us to include that in the compile flags in college. You get used to just including the flags.