<commit_before>/**
 * @fileoverview Runner is the entry point of running Tsetse checks in compiler.
 */

import * as ts from 'typescript';

import * as perfTrace from '../tsc_wrapped/perf_trace';
import * as pluginApi from '../tsc_wrapped/plugin_api';

import {Checker} from './checker';
import {AbstractRule} from './rule';
import {Rule as CheckReturnValueRule} from './rules/check_return_value_rule';
import {Rule as EqualsNanRule} from './rules/equals_nan_rule';

/**
 * The Tsetse check plugin performs compile-time static analysis for TypeScript
 * code.
 */
export const PLUGIN: pluginApi.Plugin = {
  wrap: (program: ts.Program, disabledTsetseRules: string[] = []):
            ts.Program => {
    const enabledRules: AbstractRule[] = [
      new CheckReturnValueRule(),
      new EqualsNanRule(),
    ];
    const checker = new Checker(program);
    for (const rule of enabledRules) {
      if (disabledTsetseRules.indexOf(rule.ruleName) === -1) {
        rule.register(checker);
      }
    }

    const proxy = pluginApi.createProxy(program);
    proxy.getSemanticDiagnostics = (sourceFile: ts.SourceFile) => {
      const result = program.getSemanticDiagnostics(sourceFile);
      perfTrace.wrap('checkConformance', () => {
        result.push(...checker.execute(sourceFile)
                        .map(failure => failure.toDiagnostic()));
      });
      return result;
    };
    return proxy;
  }
};
<commit_msg>allow tsetse to build on TS2.6<commit_after>/**
 * @fileoverview Runner is the entry point of running Tsetse checks in compiler.
 */

import * as ts from 'typescript';

import * as perfTrace from '../tsc_wrapped/perf_trace';
import * as pluginApi from '../tsc_wrapped/plugin_api';

import {Checker} from './checker';
import {AbstractRule} from './rule';
import {Rule as CheckReturnValueRule} from './rules/check_return_value_rule';
import {Rule as EqualsNanRule} from './rules/equals_nan_rule';

/**
 * The Tsetse check plugin performs compile-time static analysis for TypeScript
 * code.
 */
export const PLUGIN: pluginApi.Plugin = {
  wrap: (program: ts.Program, disabledTsetseRules: string[] = []):
            ts.Program => {
    const enabledRules: AbstractRule[] = [
      new CheckReturnValueRule(),
      new EqualsNanRule(),
    ];
    const checker = new Checker(program);
    for (const rule of enabledRules) {
      if (disabledTsetseRules.indexOf(rule.ruleName) === -1) {
        rule.register(checker);
      }
    }

    const proxy = pluginApi.createProxy(program);
    proxy.getSemanticDiagnostics = (sourceFile: ts.SourceFile) => {
      const result = [...program.getSemanticDiagnostics(sourceFile)];
      perfTrace.wrap('checkConformance', () => {
        result.push(...checker.execute(sourceFile)
                        .map(failure => failure.toDiagnostic()));
      });
      return result;
    };
    return proxy;
  }
};

{'fraction_non_alphanumeric': 0.13073713490959665, 'fraction_numerical': 0.0013908205841446453, 'mean_word_length': 3.206140350877193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2895527', 'n_tokens_mistral': 848, 'n_tokens_neox': 842, 'n_words': 217}