•  
      request #10205 Condition in else if is always false
    Infos
    #10205
    AppChecker (appchecker)
    2017-05-10 22:16
    2017-05-10 18:44
    10473
    Details
    Condition in else if is always false

    Hi!

     

    Please look this code fragment:

    } else if ($permission_type=='TRACKER_ACCESS_FULL') {
    return 'tracker';
    } else if ($permission_type=='TRACKER_ACCESS_FULL') {
    return 'artefact';
    }
    TRACKER_ACCESS_FULL is checked twice.

    Probably it should be:

    } else if ($permission_type=='TRACKER_ACCESS_FULL') {
    return 'tracker';
    } else if ($permission_type=='TRACKER_ARTIFACT_ACCESS') {
    return 'artefact';
    }

    This possible defect found by static code analyzer AppСhecker

    Project admin
    All
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Empty
    Stage
    Empty
    Declined
    2017-05-10
    Attachments
    Empty
    References
    References list is empty

    Follow-ups

    User avatar
    Thomas Gerbet (tgerbet)2017-05-10 22:16
    Hi,

    Thanks for the report.

    The code is indeed wrong and the suggested solution is correct.

    Impact: filtering by the permissions TRACKER_ACCESS_FULL and TRACKER_ARTIFACT_ACCESS in the project history is broken. A filter on TRACKER_ACCESS_FULL will return entries about TRACKER_ACCESS_FULL and TRACKER_ARTIFACT_ACCESS. Printable name are fine though so it's still possible to make the distinction.

    However, the code is in this state since at least 2008 and only impact trackers V3. Trackers V3 are deprecated and it is highly recommended to move to trackers v5 for instances still using it.
    In this context fixing the issue has a very low interest, as such I declined the request.

    • Status changed from New to Declined
    • Close date set to 2017-05-10