<commit_before>/*
 * Copyright 2009 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.api.plugins.quality

//import org.gradle.api.plugins.quality.internal.ConsoleReportWriter


import org.apache.tools.ant.BuildException
import org.gradle.api.GradleException
import org.gradle.api.file.FileCollection
import org.gradle.api.logging.LogLevel
import org.gradle.api.plugins.quality.internal.CodeNarcReportsImpl
import org.gradle.api.reporting.Report
import org.gradle.api.reporting.Reporting
import org.gradle.api.reporting.internal.ReportContainerBuilder
import org.gradle.api.reporting.internal.TaskGeneratedReport
import org.gradle.api.tasks.*

/**
 * Runs CodeNarc against some source files.
 */
class CodeNarc extends SourceTask implements VerificationTask, Reporting<CodeNarcReports> {
    /**
     * The class path containing the CodeNarc library to be used.
     */
    @InputFiles
    FileCollection codenarcClasspath

    /**
     * The CodeNarc configuration file to use.
     */
    @InputFile
    File configFile

    /**
     * The format type of the CodeNarc report.
     */
    @Input
    String getReportFormat() {
        reports.firstEnabled?.name
    }

    void setReportFormat(String reportFormat) {
        reports.each {
            it.enabled == it.name == reportFormat
        }
    }

    File reportFile

    @OutputFile @Optional
    File getReportFile() {
        reports.firstEnabled?.destination
    }

    void setReportFile(File reportFile) {
        reports.firstEnabled?.destination = reportFile
    }


    private final CodeNarcReportsImpl reports = ReportContainerBuilder.forTask(CodeNarcReportsImpl, TaskGeneratedReport, this).build() {
        singleFile "xml"
        singleFile "html"
        singleFile "console"
        singleFile "text"
    }

    /**
     * Whether or not the build should break when the verifications performed by this task fail.
     */
    boolean ignoreFailures

    @TaskAction
    void run() {
        logging.captureStandardOutput(LogLevel.INFO)<commit_msg>remove unused var<commit_after>/*
 * Copyright 2009 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.api.plugins.quality

//import org.gradle.api.plugins.quality.internal.ConsoleReportWriter


import org.apache.tools.ant.BuildException
import org.gradle.api.GradleException
import org.gradle.api.file.FileCollection
import org.gradle.api.logging.LogLevel
import org.gradle.api.plugins.quality.internal.CodeNarcReportsImpl
import org.gradle.api.reporting.Report
import org.gradle.api.reporting.Reporting
import org.gradle.api.reporting.internal.ReportContainerBuilder
import org.gradle.api.reporting.internal.TaskGeneratedReport
import org.gradle.api.tasks.*

/**
 * Runs CodeNarc against some source files.
 */
class CodeNarc extends SourceTask implements VerificationTask, Reporting<CodeNarcReports> {
    /**
     * The class path containing the CodeNarc library to be used.
     */
    @InputFiles
    FileCollection codenarcClasspath

    /**
     * The CodeNarc configuration file to use.
     */
    @InputFile
    File configFile

    /**
     * The format type of the CodeNarc report.
     */
    @Input
    String getReportFormat() {
        reports.firstEnabled?.name
    }

    void setReportFormat(String reportFormat) {
        reports.each {
            it.enabled == it.name == reportFormat
        }
    }

    @OutputFile @Optional
    File getReportFile() {
        reports.firstEnabled?.destination
    }

    void setReportFile(File reportFile) {
        reports.firstEnabled?.destination = reportFile
    }

    private final CodeNarcReportsImpl reports = ReportContainerBuilder.forTask(CodeNarcReportsImpl, TaskGeneratedReport, this).build() {
        singleFile "xml"
        singleFile "html"
        singleFile "console"
        singleFile "text"
    }

    /**
     * Whether or not the build should break when the verifications performed by this task fail.
     */
    boolean ignoreFailures

    @TaskAction
    void run() {
        logging.captureStandardOutput(LogLevel.INFO)
{'fraction_non_alphanumeric': 0.08026366808840636, 'fraction_numerical': 0.0031019775106630476, 'mean_word_length': 3.190901705930138, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '3527657', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1342, 'n_words': 421}