<commit_before>'use strict';

var helpers = require('../helpers');

module.exports = {
  'name': 'indentation',
  'defaults': {
    'size': 2,
    'type': 'space'
  },
  'detect': function (ast, parser) {
    var result = [];

    var processNode = function (node, level) {
      var i,
          n,
          space,
          spaceLength,
          count;


      level = level || 0;

      if (node.is('braces')) {
        return;
      }

      for (i = 0; i < node.length; i++) {
        n = node.get(i);

        if (!n) {
          continue;
        }

        if (n.type === 'space') {
          space = n.content.lastIndexOf('\n');

          if (space >= 0) {
            spaceLength = n.content.slice(space + 1).length;

            if (parser.options.type === 'space') {
              try {
                count = n.content.slice(space + 1).match(/ /g).length;
              }
              catch (e) {
                count = 0;
              }
            }
            else {
              try {
                count = n.content.slice(space + 1).match(/\/t/g).length;
              }
              catch (e) {
                count = 0;
              }
            }
            if (spaceLength / parser.options.size !== level) {
              if (count !== spaceLength) {
                result = helpers.addUnique(result, {
                  'ruleId': parser.rule.name,
                  'line': node.content[i + 1].start.line,
                  'column': node.content[i + 1].start.column,
                  'message': 'Expected indentation type of ' + parser.options.type,
                  'severity': parser.severity
                });
              }
              else if (i !== node.length - 1) {
                result = helpers.addUnique(result, {
                  'ruleId': parser.rule.name,
                  'line': node.content[i + 1].start.line,
                  'column': node.content[i + 1].start.column,
                  'message': 'Indentation of ' + spaceLength + ', expected ' + level * parser.options.size,
                  'severity': parser.severity
                });
              }
            }
          }
        }

        if (n.is('block') || n.is('atrulers') || n.is('parentheses')) {
          level++;
        }
<commit_msg>Remove Tab option<commit_after>'use strict';

var helpers = require('../helpers');

module.exports = {
  'name': 'indentation',
  'defaults': {
    'size': 2
  },
  'detect': function (ast, parser) {
    var result = [];

    var processNode = function (node, level) {
      var i,
          n,
          space,
          spaceLength,
          count;


      level = level || 0;

      if (node.is('braces')) {
        return;
      }

      for (i = 0; i < node.length; i++) {
        n = node.get(i);

        if (!n) {
          continue;
        }

        if (n.type === 'space') {
          space = n.content.lastIndexOf('\n');

          if (space >= 0) {
            spaceLength = n.content.slice(space + 1).length;

            try {
              count = n.content.slice(space + 1).match(/ /g).length;
            }
            catch (e) {
              count = 0;
            }

            if (spaceLength / parser.options.size !== level) {
              if (count !== spaceLength) {
                result = helpers.addUnique(result, {
                  'ruleId': parser.rule.name,
                  'line': node.content[i + 1].start.line,
                  'column': node.content[i + 1].start.column,
                  'message': 'Mixed tabs and spaces',
                  'severity': parser.severity
                });
              }
              if (i !== node.length - 1) {
                result = helpers.addUnique(result, {
                  'ruleId': parser.rule.name,
                  'line': node.content[i + 1].start.line,
                  'column': node.content[i + 1].start.column,
                  'message': 'Indentation of ' + spaceLength + ', expected ' + level * parser.options.size,
                  'severity': parser.severity
                });
              }
            }
          }
        }

        if (n.is('block') || n.is('atrulers') || n.is('parentheses')) {
          level++;
        }

{'fraction_non_alphanumeric': 0.14894624674402085, 'fraction_numerical': 0.006156760596732181, 'mean_word_length': 1.1954261954261953, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5252559', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1186, 'n_words': 252}