spotbugs / discuss

SpotBugs mailing list
6 stars 1 forks source link

Not logged exception #49

Open gergopapi2 opened 6 years ago

gergopapi2 commented 6 years ago

Dear Spotbugs Team,

in our code we would like to spot issues like these:

1.

  try{
      ...
  } catch (AnyException e){
     // doing nothing, no rethrow, no logging ...
  }

Or 2.

  try{
  ...
  } catch (SomeThirdPartyException e){
     // no logging, and original exception not passed to MyCustomException
     throw new MyCustomException("some bad description")
  }

Does Spotbugs detect such issues? Reading through the bug pattern list I thought DE_MIGHT_DROP or DE_MIGHT_IGNORE would detect case 1., but somehow it did not.

So my questions:

Thank you very much for your help in advance, Gergely

Our setup:

java 10 we use the gradle plugin

    apply plugin: 'com.github.spotbugs'
    spotbugs {
      toolVersion = "3.1.5"
      excludeFilter = file("$rootProject.projectDir/config/spotbugs/excludeFilter.xml")
      effort = "min"  // tried also max
  }
    tasks.withType(com.github.spotbugs.SpotBugsTask) {
      reports {
        xml.enabled false
        html.enabled true
      }
    }

No includeFilter was used.

Content of excludeFilter.xml ():

  <FindBugsFilter>
     <Match>
        <Bug pattern="DM_DEFAULT_ENCODING" />
    </Match>
    <Match>
        <Bug pattern="EI_EXPOSE_REP" />
    </Match>
    <Match>
        <Bug pattern="EI_EXPOSE_REP2" />
    </Match>
    <Match>
        <Bug pattern="UC_USELESS_VOID_METHOD" />
    </Match>
    <Match>
        <Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
    </Match>
    <Match>
        <!-- False positive: https://github.com/spotbugs/spotbugs/issues/432 -->
        <Bug pattern="OBL_UNSATISFIED_OBLIGATION" />
    </Match>
    <Match>
        <Class name="~.*MapperImpl$"/>
    </Match>
    <Match>
        <Class name="<DELETED>"/>
    </Match>
</FindBugsFilter>

Please let me know if you need further details

vorburger commented 6 years ago

@gergopapi2 are you aware of @KengoTODA's https://github.com/KengoTODA/findbugs-slf4j ?

vorburger commented 6 years ago

@gergopapi2 specifically this is actually what I proposed in https://github.com/KengoTODA/findbugs-slf4j/issues/74 ...

gergopapi2 commented 6 years ago

@vorburger thank you very much following up on my mail and pointing me to your PR in KengoTODA's repo. Yes, that is something we would like to have - I will keep an eye on it and let my team know about this.

Would your PR detect also the following pattern?

try{
  ...
  } catch (SomeThirdPartyException e){
     // no logging, and original exception not passed to MyCustomException
     throw new MyCustomException("some bad description")
  }