If you live in Portugal for longer than 6 months every 12 months you are considered a resident and taxed accordingly. I suppose you could go in and out every few months to escape that.
Just to note, it is a little bit more complicated, as there are other aspects of a tax residency test as well. IE, if it is your "home" as dictated by some other rules it can be a tax residency even with less time spent there.