Uploaded image for project: 'Stanbol (Retired)'
  1. Stanbol (Retired)
  2. STANBOL-1461

Possible code smell that returns always true in conditions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • None
    • None
    • Commons, Enhancer
    • None

    Description

      Hi

      In a recent code snapshot from GitHub, I've found following suspicious code.

      Path: commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/ClassPathDataFileProvider.java

      101     private URL getDataFile(String bundleSymbolicName, String filename) {
      102         //if the parsed bundleSymbolicName is null accept any request
      103         //if not, than check if the request is from the correct bundle.
      104         if(bundleSymbolicName != null && !bundleSymbolicName.equals(bundleSymbolicName)) {
      105             log.debug("Requested bundleSymbolicName {} does not match mine ({}), request ignored",
      106                     bundleSymbolicName, symbolicName);
      107             return null;
      108         }
      

      In Line 104, bundleSymbolicName.equals(bundleSymbolicName) should be bundleSymbolicName.equals(symbolicName)?

      Path: enhancer/generic/nlp-json/src/main/java/org/apache/stanbol/enhancer/nlp/json/valuetype/impl/PosTagSupport.java

      135         public boolean equals(Object obj) {
      136             return obj instanceof PosTagInfo && tag.equals(tag) &&
      137                     categories.equals(categories) && pos.equals(pos);
      138         }
      

      In Line 136 and 137, there are conditions comparing the same objects.

      These might not be issue if the code is not playable in real world. But wanted to report just in case. Thanks!

      Attachments

        Activity

          People

            Unassigned Unassigned
            lifove JC
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: