Avoid too much nesting

This commit is contained in:
ByteHamster 2019-12-02 10:30:49 +01:00
parent cbcd97f6c9
commit 26e91c0b81
4 changed files with 175 additions and 164 deletions

View File

@ -244,5 +244,14 @@
<property name="exceptionVariableName" value="expected"/> <property name="exceptionVariableName" value="expected"/>
</module> </module>
<module name="CommentsIndentation"/> <module name="CommentsIndentation"/>
<module name="NestedIfDepth">
<property name="max" value="4"/>
</module>
<module name="NestedTryDepth">
<property name="max" value="2"/>
</module>
<module name="NestedForDepth">
<property name="max" value="2"/>
</module>
</module> </module>
</module> </module>

View File

@ -91,5 +91,14 @@
<property name="tokens" value="VARIABLE_DEF"/> <property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/> <property name="allowSamelineMultipleAnnotations" value="true"/>
</module> </module>
<module name="NestedIfDepth">
<property name="max" value="4"/>
</module>
<module name="NestedTryDepth">
<property name="max" value="2"/>
</module>
<module name="NestedForDepth">
<property name="max" value="2"/>
</module>
</module> </module>
</module> </module>

View File

@ -97,12 +97,10 @@ public class NSAtom extends Namespace {
type = SyndTypeUtils.getMimeTypeFromUrl(href); type = SyndTypeUtils.getMimeTypeFromUrl(href);
} }
if(SyndTypeUtils.enclosureTypeValid(type)) {
FeedItem currItem = state.getCurrentItem(); FeedItem currItem = state.getCurrentItem();
if(currItem != null && !currItem.hasMedia()) { if (SyndTypeUtils.enclosureTypeValid(type) && currItem != null && !currItem.hasMedia()) {
currItem.setMedia(new FeedMedia(currItem, href, size, type)); currItem.setMedia(new FeedMedia(currItem, href, size, type));
} }
}
} else if (LINK_REL_PAYMENT.equals(rel)) { } else if (LINK_REL_PAYMENT.equals(rel)) {
state.getCurrentItem().setPaymentLink(href); state.getCurrentItem().setPaymentLink(href);
} }

View File

@ -47,23 +47,18 @@ public class ID3Reader {
onEndTag(); onEndTag();
} else { } else {
while (readerPosition < tagHeader.getSize()) { while (readerPosition < tagHeader.getSize()) {
FrameHeader frameHeader = createFrameHeader(readBytes( FrameHeader frameHeader = createFrameHeader(readBytes(input, HEADER_LENGTH));
input, HEADER_LENGTH));
if (checkForNullString(frameHeader.getId())) { if (checkForNullString(frameHeader.getId())) {
break; break;
} else { }
rc = onStartFrameHeader(frameHeader, input); rc = onStartFrameHeader(frameHeader, input);
if (rc == ACTION_SKIP) { if (rc == ACTION_SKIP) {
if (frameHeader.getSize() + readerPosition > tagHeader.getSize()) {
if (frameHeader.getSize() + readerPosition > tagHeader
.getSize()) {
break; break;
} else { }
skipBytes(input, frameHeader.getSize()); skipBytes(input, frameHeader.getSize());
} }
} }
}
}
onEndTag(); onEndTag();
} }
} }