@Restricted(NoExternalUse.class)
    public static boolean calculateIfSecret(@CheckForNull Class<?> targetClass, @NonNull String fieldName) {
        if (targetClass == Secret.class) { // Class is final, so the check is safe
            LOGGER.log(Level.FINER, "Attribute {0}#{1} is secret, because it has a Secret type", new Object[] {
                targetClass.getName(), fieldName
            });
            return true;
        }

        if (targetClass == null) {
            LOGGER.log(
                    Level.FINER,
                    "Attribute {0} is assumed to be non-secret, because there is no class instance in the call. "
                            + "This call is used only for fast-fetch caching, and the result may be adjusted later",
                    new Object[] {fieldName});
            return false; // All methods below require a known target class
        }

        // TODO: Cache decisions?

        Method m = locateGetter(targetClass, fieldName);
        if (m != null && m.getReturnType() == Secret.class) {
            LOGGER.log(
                    Level.FINER,
                    "Attribute {0}#{1} is secret, because there is a getter {2} which returns a Secret type",
                    new Object[] {targetClass.getName(), fieldName, m});
            return true;
        }

        Field f = locatePublicField(targetClass, fieldName);
        if (f != null && f.getType() == Secret.class) {
            LOGGER.log(
                    Level.FINER,
                    "Attribute {0}#{1} is secret, because there is a public field {2} which has a Secret type",
                    new Object[] {targetClass.getName(), fieldName, f});
            return true;
        }

        f = locatePrivateFieldInHierarchy(targetClass, fieldName);
        if (f != null && f.getType() == Secret.class) {
            LOGGER.log(
                    Level.FINER,
                    "Attribute {0}#{1} is secret, because there is a private field {2} which has a Secret type",
                    new Object[] {targetClass.getName(), fieldName, f});
            return true;
        }

        // TODO(oleg_nenashev): Consider setters? Gonna be more interesting since there might be many of them
        LOGGER.log(Level.FINER, "Attribute {0}#{1} is not a secret, because all checks have passed", new Object[] {
            targetClass.getName(), fieldName
        });
        return false;
    }
This is a method which tries to guess whether an attribute is {@link Secret}.
@param targetClass Class of the target object. {@code null} if unknown
@param fieldName Field name
@return {@code true} if the attribute is secret
        {@code false} if not or if there is no conclusive answer.
plugin/src/main/java/io/jenkins/plugins/casc/Attribute.java