<commit_before>"use strict";

import {SAXParser} from 'parse5';
import {Rule} from '../rule';
import {ParseState} from '../parse-state';
import {Issue, IssueSeverity} from '../issue';

/**
 * Rule to ensure tags are properly closed. 
 */
export class ObsoleteTagRule extends Rule {
    private parseState: ParseState;

    obsoletes: Array<{ tag: string, msg?: string }>

    constructor(obsolete?: Array<{ tag: string, msg?: string }>) {
        super();

        this.obsoletes = obsolete ? obsolete : []
    }

    init(parser: SAXParser, parseState: ParseState) {
        parser.on("startTag", (tag, attrs, selfClosing, loc) => {            
            if (this.obsoletes.find(x => x.tag == tag)) {
                let issue = new Issue({
                    message: `<${tag}> is obsolete`,
                    severity: IssueSeverity.Error,
                    line: loc.line,
                    column: loc.col,
                });
                this.reportIssue(issue);
            }
        });
    }
}<commit_msg>use obsolete tag detail msg<commit_after>"use strict";

import {SAXParser} from 'parse5';
import {Rule} from '../rule';
import {ParseState} from '../parse-state';
import {Issue, IssueSeverity} from '../issue';

/**
 * Rule to ensure tags are properly closed. 
 */
export class ObsoleteTagRule extends Rule {
    private parseState: ParseState;

    obsoletes: Array<{ tag: string, msg?: string }>

    constructor(obsolete?: Array<{ tag: string, msg?: string }>) {
        super();

        this.obsoletes = obsolete ? obsolete : []
    }

    init(parser: SAXParser, parseState: ParseState) {
        parser.on("startTag", (tag, attrs, selfClosing, loc) => {            
            var obsolete = this.obsoletes.find(x => x.tag == tag);
            if (obsolete) {
                let issue = new Issue({
                    message: `<${tag}> is obsolete`,
                    severity: IssueSeverity.Error,
                    line: loc.line,
                    column: loc.col, 
                    detail: obsolete.msg || "",             
                });
                this.reportIssue(issue);
            }
        });
    }
}
{'fraction_non_alphanumeric': 0.13705583756345177, 'fraction_numerical': 0.0009229349330872173, 'mean_word_length': 1.837696335078534, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '5910685', 'n_tokens_mistral': 634, 'n_tokens_neox': 589, 'n_words': 165}