<commit_before>/*
 * Copyright 2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.execution.plan;

import org.gradle.internal.MutableBoolean;
import org.gradle.internal.reflect.TypeValidationContext;

import javax.annotation.Nullable;

public class DefaultNodeValidator implements NodeValidator {
    @Override
    public boolean hasValidationProblems(Node node) {
        if (node instanceof LocalTaskNode) {
            MutableBoolean foundProblem = new MutableBoolean();
            TypeValidationContext context = new TypeValidationContext() {
                @Override
                public void visitTypeProblem(Severity severity, Class<?> type, String message) {
                    if (severity != Severity.CACHEABILITY_WARNING) {
                        foundProblem.set(true);
                    }
                }

                @Override
                public void visitPropertyProblem(Severity severity, @Nullable String parentProperty, @Nullable String property, String message) {
                    if (severity != Severity.CACHEABILITY_WARNING) {
                        foundProblem.set(true);
                    }
                }
            };
            ((LocalTaskNode) node).getTaskProperties().validateType(context);
            return foundProblem.get();
        } else {
            return false;
        }
    }
}<commit_msg>Add comment why we ignore cacheability problems<commit_after>/*
 * Copyright 2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.execution.plan;

import org.gradle.internal.MutableBoolean;
import org.gradle.internal.reflect.TypeValidationContext;

import javax.annotation.Nullable;

public class DefaultNodeValidator implements NodeValidator {
    @Override
    public boolean hasValidationProblems(Node node) {
        if (node instanceof LocalTaskNode) {
            MutableBoolean foundProblem = new MutableBoolean();
            TypeValidationContext context = new TypeValidationContext() {
                @Override
                public void visitTypeProblem(Severity severity, Class<?> type, String message) {
                    recordNonCacheabilityProblem(severity);
                }

                @Override
                public void visitPropertyProblem(Severity severity, @Nullable String parentProperty, @Nullable String property, String message) {
                    recordNonCacheabilityProblem(severity);
                }

                private void recordNonCacheabilityProblem(Severity severity) {
                    // We don't know whether the task is cacheable or not, so we ignore cacheability problems for scheduling
                    if (severity != Severity.CACHEABILITY_WARNING) {
                        foundProblem.set(true);
                    }
                }
            };
            ((LocalTaskNode) node).getTaskProperties().validateType(context);
            return foundProblem.get();
        } else {
            return false;
        }
    }
}
{'fraction_non_alphanumeric': 0.07, 'fraction_numerical': 0.003902439024390244, 'mean_word_length': 2.3864574731626753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4445174', 'n_tokens_mistral': 980, 'n_tokens_neox': 901, 'n_words': 331}