<commit_before>var Errors = require('./errors')
  , fs = require('fs')
  , glob = require('glob')
  , StylusFile = require('./stylus-file')

  , Linter = function () {}

Linter.prototype =
  { checkFile: function (filename) {

      return this.checkString(fs.readFileSync(filename, 'utf8'))

  }

  , checkString: function (source, filename) {

      filename = filename || 'input'

      var file = this._createStylusFile(filename, source)

      return this._checkStylusFile(file)

    }

  , configure: function (options) {

      this._configuredRules = []

      glob.sync(__dirname + '/rules/*.js').forEach(function (file) {
        var Rule = require(file)
          , rule = new Rule()

        if (options && options.hasOwnProperty(rule.name) && options[rule.name] !== null) {
          rule.configure(options[rule.name])

          this._configuredRules.push(rule)
        }
      }, this)

    }

  , getConfiguredRules: function () {

    return this._configuredRules

  }

  , _checkStylusFile: function (file) {

      var errors = new Errors(file)

      file.getParseErrors().forEach(function (parseError) {
        errors.addParseError(parseError)
      })

      var firstToken = file.getToken(0)

      if (firstToken && firstToken.type === 'eos') {
        return errors
      }

      this.getConfiguredRules().forEach(function (rule) {
        errors.setCurrentRule(rule.name)

        rule.lint(file, errors)
      })

      return errors

    }

  , _createStylusFile: function (filename, source) {

      return new StylusFile(filename, source)

    }
  }

module.exports = Linter<commit_msg>> Catch empty token collections<commit_after>var Errors = require('./errors')
  , fs = require('fs')
  , glob = require('glob')
  , StylusFile = require('./stylus-file')

  , Linter = function () {}

Linter.prototype =
  { checkFile: function (filename) {

      return this.checkString(fs.readFileSync(filename, 'utf8'))

  }

  , checkString: function (source, filename) {

      filename = filename || 'input'

      var file = this._createStylusFile(filename, source)

      return this._checkStylusFile(file)

    }

  , configure: function (options) {

      this._configuredRules = []

      glob.sync(__dirname + '/rules/*.js').forEach(function (file) {
        var Rule = require(file)
          , rule = new Rule()

        if (options && options.hasOwnProperty(rule.name) && options[rule.name] !== null) {
          rule.configure(options[rule.name])

          this._configuredRules.push(rule)
        }
      }, this)

    }

  , getConfiguredRules: function () {

    return this._configuredRules

  }

  , _checkStylusFile: function (file) {

      var errors = new Errors(file)

      file.getParseErrors().forEach(function (parseError) {
        errors.addParseError(parseError)
      })

      var firstToken = file.getToken(0)

      if (!firstToken || firstToken && firstToken.type === 'eos') {
        return errors
      }

      this.getConfiguredRules().forEach(function (rule) {
        errors.setCurrentRule(rule.name)

        rule.lint(file, errors)
      })

      return errors

    }

  , _createStylusFile: function (filename, source) {

      return new StylusFile(filename, source)

    }
  }

module.exports = Linter
{'fraction_non_alphanumeric': 0.13153869684918937, 'fraction_numerical': 0.001223615784643622, 'mean_word_length': 2.6052921719955897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '860511', 'n_tokens_mistral': 1026, 'n_tokens_neox': 969, 'n_words': 188}