I am using rust, but this applies to many other languages, I get warnings like, dead code, unused variables, and etc, and while I remove most of them, there are some im not sure of, I like running my program and there being 0 warnings, or 0 warnings as i scroll down my code, so for things im unsure of, i mark them so the compiler doesn’t put warnings there. I also add comments, starting with TODO:, it has some information about what to think about when i revisit it, also the todo’s gets highlighed in my IDE with my extension, but is this bad practice?

  • vext01@feddit.uk
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    It’s not ideal.

    Depending on the kind of warning, you may be able to re-write the code in question including a ‘todo!()’ to capture the “i need to think about this” case.

    This way you get a crash at runtime. This is preferable to continuing execution with incorrect computation.

    It’s best just to fix the warnings ASAP. They are usually trivial anyway.

  • nous@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 months ago

    I treat warning as todos. Fix them all before I release something. I would only ever disable one if I know for a fact the warning is a false positive.

    I would question why you are seeing so many warnings you are not sure about? If you keep on top of them you really shouldn’t have that many. Marking them all as allowed with a Todo comment feels just like you are burying you head in the sand.

    I would leave them all there to keep nudging you to investigate and remove them. Hiding them behind a Todo will just mean you will ignore them. And warnings are important, they very likely point to a problem, even if that is just the code could be simpler. It is rare they are true false positives.

  • one_old_coder@piefed.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    It is bad practice. You’ll obviously have 0 warnings if you hide the warnings. You don’t go from warnings to YOLO mode. You should compile with “warnings as errors” and fix those if you want to really remove those warnings.