<commit_before>const semver = require('semver')
const BaseChecker = require('./../base-checker')

const ruleId = 'compiler-version'
const meta = {
  type: 'security',

  docs: {
    description: `Compiler version must satisfy a semver requirement.`,
    category: 'Security Rules'
  },

  isDefault: false,
  recommended: true,
  defaultSetup: ['error', '^0.5.7'],

  schema: [
    {
      type: 'array',
      items: [{ type: 'string' }],
      uniqueItems: true,
      minItems: 2
    }
  ]
}

class CompilerGTChecker extends BaseChecker {
  constructor(reporter, config) {
    super(reporter, ruleId, meta)

    this.requirement = (config && config.getString(ruleId, '^0.5.8')) || '^0.5.8'
  }

  exitVersionConstraint(ctx) {
    const versionNode =
      (this.isVersionOperator(ctx.children[0]) && ctx.children[1]) || ctx.children[0]

    if (!semver.satisfies(versionNode.getText(), this.requirement)) {
      this.error(
        ctx,
        `Compiler version ${versionNode.getText()} does not satisfy the ${
          this.requirement
        }semver requirement`
      )
    }
  }

  isVersionOperator(ctx) {
    return ctx.constructor.name.includes('VersionOperator')
  }
}

module.exports = CompilerGTChecker<commit_msg>Change class name to CompilerVersionChecker and add space in the description error<commit_after>const semver = require('semver')
const BaseChecker = require('./../base-checker')

const ruleId = 'compiler-version'
const meta = {
  type: 'security',

  docs: {
    description: `Compiler version must satisfy a semver requirement.`,
    category: 'Security Rules'
  },

  isDefault: false,
  recommended: true,
  defaultSetup: ['error', '^0.5.7'],

  schema: [
    {
      type: 'array',
      items: [{ type: 'string' }],
      uniqueItems: true,
      minItems: 2
    }
  ]
}

class CompilerVersionChecker extends BaseChecker {
  constructor(reporter, config) {
    super(reporter, ruleId, meta)

    this.requirement = (config && config.getString(ruleId, '^0.5.8')) || '^0.5.8'
  }

  exitVersionConstraint(ctx) {
    const versionNode =
      (this.isVersionOperator(ctx.children[0]) && ctx.children[1]) || ctx.children[0]

    if (!semver.satisfies(versionNode.getText(), this.requirement)) {
      this.error(
        ctx,
        `Compiler version ${versionNode.getText()} does not satisfy the ${
          this.requirement
        } semver requirement`
      )
    }
  }

  isVersionOperator(ctx) {
    return ctx.constructor.name.includes('VersionOperator')
  }
}

module.exports = CompilerVersionChecker
{'fraction_non_alphanumeric': 0.13926042486231313, 'fraction_numerical': 0.010228166797797011, 'mean_word_length': 3.1756978653530377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '352445', 'n_tokens_mistral': 799, 'n_tokens_neox': 793, 'n_words': 174}