kitodo / kitodo-ugh

Kitodo.UGH Library
2 stars 10 forks source link

Wrong use of parameter, reveals dead code #52

Closed matthias-ronge closed 7 years ago

matthias-ronge commented 7 years ago

The class DocStruct provides the three methods

All of them should prevent the deletion of the meta-data, preson, or meta-data group object in the case the quantity is set to 1m or +. The behaviour can be overriden by setting the boolean parameter force to true. However, the syntax of the if checks misses the required negation, turning the function to behave just the opposite (only checking for 1m or + in case force is true). I wondered why nobody ever noticed, and found out that the function is always only called from another delegate function,

with force set to false. Thus the checks never apply. Code can be refactored to

henning-gerhardt commented 7 years ago

As long as return value of this methods are not evaluated / used (at least in Kitodo.Production), this methods could be simplified.