<commit_before>package de.codescape.bitvunit.rule.tables;

import com.gargoylesoftware.htmlunit.html.HtmlTable;
import com.gargoylesoftware.htmlunit.html.HtmlTableCell;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
import de.codescape.bitvunit.model.Page;
import de.codescape.bitvunit.rule.AbstractRule;
import de.codescape.bitvunit.rule.Violations;

import static de.codescape.bitvunit.util.html.HtmlTableCellUtil.isDataCell;
import static de.codescape.bitvunit.util.html.HtmlTableCellUtil.isHeaderCell;

/**
 * TableHeaderForTableColumnRule ensures that every <code>&lt;table /&gt;</code> within the given HTML document has
 * table headers declared by <code>&lt;th /&gt;</code> for each data cell declared by <code>&gt;td /&gt;</code>.
 *
 * @author <NAME>
 * @since 0.3
 */
public class TableHeaderForTableColumnRule extends AbstractRule {

    private static final String RULE_NAME = "TableHeaderForTableColumn";
    private static final String RULE_MESSAGE = "Every data cell should have an associated column header cell.";
    private static final String RULE_MESSAGE_SINGLE_ROW = "Tables with a row count of one are missing data cells or header cells.";

    @Override
    public String getName() {
        return RULE_NAME;
    }

    @Override
    protected void applyTo(Page page, Violations violations) {
        for (HtmlTable table : page.findAllTableTags()) {
            applyTo(table, violations);
        }
    }

    private void applyTo(HtmlTable table, Violations violations) {
        if (table.getRowCount() < 2) {
            violations.add(createViolation(table, RULE_MESSAGE_SINGLE_ROW));
        } else {
            HtmlTableRow firstRow = table.getRow(0);
            HtmlTableRow secondRow = table.getRow(1);

            int index = 0;
            for (HtmlTableCell secondRowCell : secondRow.getCells()) {
                if (isDataCell(secondRowCell) && !isHeaderCell(firstRow.getCell(index))) {
                    violations.add(createViolation(secondRowCell, RULE_MESSAGE));
                }
                index++;
            }
        }
    }

}
<commit_msg>wrong javadoc<commit_after>package de.codescape.bitvunit.rule.tables;

import com.gargoylesoftware.htmlunit.html.HtmlTable;
import com.gargoylesoftware.htmlunit.html.HtmlTableCell;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
import de.codescape.bitvunit.model.Page;
import de.codescape.bitvunit.rule.AbstractRule;
import de.codescape.bitvunit.rule.Violations;

import static de.codescape.bitvunit.util.html.HtmlTableCellUtil.isDataCell;
import static de.codescape.bitvunit.util.html.HtmlTableCellUtil.isHeaderCell;

/**
 * TableHeaderForTableColumnRule ensures that every <code>&lt;table /&gt;</code> within the given HTML document has
 * table headers declared by <code>&lt;th /&gt;</code> for each data cell declared by <code>&lt;td /&gt;</code>.
 *
 * @author <NAME>
 * @since 0.3
 */
public class TableHeaderForTableColumnRule extends AbstractRule {

    private static final String RULE_NAME = "TableHeaderForTableColumn";
    private static final String RULE_MESSAGE = "Every data cell should have an associated column header cell.";
    private static final String RULE_MESSAGE_SINGLE_ROW = "Tables with a row count of one are missing data cells or header cells.";

    @Override
    public String getName() {
        return RULE_NAME;
    }

    @Override
    protected void applyTo(Page page, Violations violations) {
        for (HtmlTable table : page.findAllTableTags()) {
            applyTo(table, violations);
        }
    }

    private void applyTo(HtmlTable table, Violations violations) {
        if (table.getRowCount() < 2) {
            violations.add(createViolation(table, RULE_MESSAGE_SINGLE_ROW));
        } else {
            HtmlTableRow firstRow = table.getRow(0);
            HtmlTableRow secondRow = table.getRow(1);

            int index = 0;
            for (HtmlTableCell secondRowCell : secondRow.getCells()) {
                if (isDataCell(secondRowCell) && !isHeaderCell(firstRow.getCell(index))) {
                    violations.add(createViolation(secondRowCell, RULE_MESSAGE));
                }
                index++;
            }
        }
    }

}

{'fraction_non_alphanumeric': 0.09672830725462304, 'fraction_numerical': 0.002844950213371266, 'mean_word_length': 3.219, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4337798', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1230, 'n_words': 291}