CocoaPods/Core

if this is a bug or Comment error in the class Pod::Podfile::TargetDefinition

talka123456 opened this issue · 3 comments

In line 937 of the current class, when inhibit_warnings_hash processes the hash table,
the comment content (Remove pods that are set to inhibit inside parent if they are set to not inhibit inside current target.) indicates that the pods(not inhibit inside) in current target is removed from the patent, but the code uses "for_pods"

parent_hash['for_pods'] -= Array(inhibit_hash['for_pods'])

i think it should be parent_hash['for_pods'] -= Array(inhibit_hash['not_for_pods'])

use module header also has the same problem

can you open a PR with a test to showcase the issue?

@dnkoutso I'm sorry I don't know much about ruby's test method, so I directly mentioned a modification pr: fixed bug for the target definition of podfile, I hope you review

@dnkoutso
Another question is, in the function inhibition_warnings_for_pod that judges whether the specified dependency is enabled for inhibition_warnings?, why call the function of the parent node recursive in the third branch, the inhibit_warnings_hash function has recursively processed the data of the parent node and merged into the current inhibition_warnings_hash return value In, I think the use of inhibit_warnings_hash is enough to judge and deal with,

def inhibits_warnings_for_pod?(pod_name)
        if Array(inhibit_warnings_hash['not_for_pods']).include?(pod_name)
          false
        elsif inhibit_warnings_hash['all']
          true
        elsif !root? && parent.inhibits_warnings_for_pod?(pod_name)
          true
        else
          Array(inhibit_warnings_hash['for_pods']).include? pod_name
        end
      end

I think this judgment branch( elsif !root? && parent.inhibits_warnings_for_pod?(pod_name)) is redundant, it causes recursive calls to be processed multiple times

I have less understanding of cocoapods, please advise, thanks