Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotation class returns undocumented nulls #458

Closed
julesjacobsen opened this issue Jun 25, 2019 · 0 comments
Closed

Annotation class returns undocumented nulls #458

julesjacobsen opened this issue Jun 25, 2019 · 0 comments
Milestone

Comments

@julesjacobsen
Copy link
Contributor

julesjacobsen commented Jun 25, 2019

Annotation.getPutativeImpact() and Annotation.getMostPathogenicVarType() can both return a null, yet there are no @Nullable annotations on these methods to enable code inspection tools to make the end-user aware of this hidden gem of excitement.

These stem from the effects field being an empty list:

public VariantEffect getMostPathogenicVarType() {
    return this.effects.isEmpty() ? null : (VariantEffect)this.effects.iterator().next();
}

public PutativeImpact getPutativeImpact() {
    if (this.effects.isEmpty()) {
        return null;
    } else {
        VariantEffect worst = (VariantEffect)this.effects.iterator().next();
        UnmodifiableIterator var2 = this.effects.iterator();
...
}

could these be changed to return the lowest effect/impact:

public VariantEffect getMostPathogenicVarType() {
    return this.effects.isEmpty() ? VariantEffect.SEQUENCE_VARIANT : (VariantEffect) this.effects.iterator().next();
}

public PutativeImpact getPutativeImpact() {
    if (this.effects.isEmpty()) {
        return PutativeImpact.MODIFIER;
    } else {
        VariantEffect worst = (VariantEffect) this.effects.iterator().next();
        UnmodifiableIterator var2 = this.effects.iterator();
...
}

Alternatively the EMPTY_VARIANT_EFFECTS field could be changed to SEQUENCE_VARIANT_EFFECT which is assigned in the constructor:

    private static final ImmutableSet<VariantEffect> EMPTY_VARIANT_EFFECTS = Sets.immutableEnumSet(EnumSet.noneOf(VariantEffect.class));

    this.effects = varTypes == null ? EMPTY_VARIANT_EFFECTS : Sets.immutableEnumSet(varTypes);

becomes:

    private static final ImmutableSet<VariantEffect> SEQUENCE_VARIANT_EFFECT = Sets.immutableEnumSet(VariantEffect.SEQUENCE_VARIANT));

    this.effects = (varTypes == null ||  varTypes.isEmpty()) ? SEQUENCE_VARIANT_EFFECT : Sets.immutableEnumSet(varTypes);

and then getMostPathogenicVarType() and getPutativeImpact() can be simplified:

public VariantEffect getMostPathogenicVarType() {
    return (VariantEffect) this.effects.iterator().next();
}

public PutativeImpact getPutativeImpact() {
    VariantEffect worst = (VariantEffect) this.effects.iterator().next();
    UnmodifiableIterator var2 = this.effects.iterator();
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants