• lambisio@feddit.cl
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 hours ago

    This can’t stop me because I don’t even know any of my code well enough to think whether it’s useless in the first place!

  • Quetzalcutlass@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    ·
    3 days ago

    This is why I love the “find usages” inspection, though the IDE (at least JetBrains ones) will usually preemptively warn you about unused methods and functions.

    If it’s a block of logic in the middle of a function that you suspect is no longer needed, set a breakpoint in it and run the program before deleting it just to make sure it’s not being triggered.

    • ryannathans@aussie.zone
      link
      fedilink
      arrow-up
      6
      ·
      3 days ago

      Deeper down the rabbit hole, more dangerous “useless” blocks of code won’t be found with “find usages” because the usage either:

      1. isn’t in the project, and is external. Like a powershell script calling a function present in the DLL, or your system’s equivalent. Or even hardware accessing it directly at a known address, like an IRQ table

      2. is accessed via reflection, which the IDE won’t know about

      3. for bonus points, the linker depends on it to make a functioning binary. Or some other dodgy code may break at runtime if offset from its original location in the binary…

  • Omega_Jimes@lemmy.ca
    link
    fedilink
    arrow-up
    4
    ·
    3 days ago

    That’s why we comment first, then use version controls. Also we never test in prod.

    ROFL yeah right!

  • printf("%s", name);@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 days ago

    Fortunately:

    1. I quit the editor without saving the changes
    2. I have a previous version that still contains the block in question
    3. I have a few onions on which I can blame my tears
  • Hayduke@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 days ago

    Oof, just did that a couple of days ago, in prod no less (not able to test particular change in lower envs). Good times.