<commit_before>path = require 'path'
vows = require 'vows'
assert = require 'assert'
coffeelint = require path.join('..', 'lib', 'coffeelint')


vows.describe('indent').addBatch({

    'Indentation' :

        topic : () ->
            """
            x = () ->
              'two spaces'

            a = () ->
                'four spaces'
            """

        'defaults to two spaces' : (source) ->
            errors = coffeelint.lint(source)
            assert.equal(errors.length, 1)
            error = errors[0]
            assert.include(error.evidence, 'four spaces')
            assert.equal(error.line, 4)

        'can be overridden' : (source) ->
            errors = coffeelint.lint(source, {indent:4})
            assert.equal(errors.length, 1)
            error = errors[0]
            assert.include(error.evidence, 'two spaces')
            assert.equal(error.line, 1)

        'is optional' : (source) ->
            errors = coffeelint.lint(source, {indent:false})
            assert.equal(errors.length, 0)

    'Nested indentation errors' :

        topic : () ->
            """
            x = () ->
              y = () ->
                  1234
            """

        'are caught' : (source) ->
            errors = coffeelint.lint(source)
            assert.equal(errors.length, 1)
            error = errors[0]
            assert.equal(error.line, 2)

    'Compiler generated indentation' :

        topic : () ->
            """
            () ->
                if 1 then 2 else 3
            """

        'is ignored when not using two spaces' : (source) ->
            errors = coffeelint.lint(source, {indent: 4})
            assert.isEmpty(errors)

    'Indentation inside interpolation' :

        topic : 'a = "#{ 1234 }"'

        'is ignored' : (source) ->
            errors = coffeelint.lint(source)
            assert.isEmpty(errors)

    'Indentation in multi-line expressions' :

        topic : """
        x = '1234' + '1234' + '1234' +
                '1234' + '1234'
        """

        'is ignored' : (source) ->
            errors = coffeelint.lint(source)
            assert.isEmpty(errors)




}).export(module)<commit_msg>Use assert.lengthOf instead of assert.equal.<commit_after>path = require 'path'
vows = require 'vows'
assert = require 'assert'
coffeelint = require path.join('..', 'lib', 'coffeelint')


vows.describe('indent').addBatch({

    'Indentation' :

        topic : () ->
            """
            x = () ->
              'two spaces'

            a = () ->
                'four spaces'
            """

        'defaults to two spaces' : (source) ->
            errors = coffeelint.lint(source)
            assert.equal(errors.length, 1)
            error = errors[0]
            assert.include(error.evidence, 'four spaces')
            assert.equal(error.line, 4)

        'can be overridden' : (source) ->
            errors = coffeelint.lint(source, {indent:4})
            assert.equal(errors.length, 1)
            error = errors[0]
            assert.include(error.evidence, 'two spaces')
            assert.equal(error.line, 1)

        'is optional' : (source) ->
            errors = coffeelint.lint(source, {indent:false})
            assert.equal(errors.length, 0)

    'Nested indentation errors' :

        topic : () ->
            """
            x = () ->
              y = () ->
                  1234
            """

        'are caught' : (source) ->
            errors = coffeelint.lint(source)
            assert.lengthOf(errors, 1)
            error = errors[0]
            assert.equal(error.line, 2)

    'Compiler generated indentation' :

        topic : () ->
            """
            () ->
                if 1 then 2 else 3
            """

        'is ignored when not using two spaces' : (source) ->
            errors = coffeelint.lint(source, {indent: 4})
            assert.isEmpty(errors)

    'Indentation inside interpolation' :

        topic : 'a = "#{ 1234 }"'

        'is ignored' : (source) ->
            errors = coffeelint.lint(source)
            assert.isEmpty(errors)

    'Indentation in multi-line expressions' :

        topic : """
        x = '1234' + '1234' + '1234' +
                '1234' + '1234'
        """

        'is ignored' : (source) ->
            errors = coffeelint.lint(source)
            assert.isEmpty(errors)

}).export(module)
{'fraction_non_alphanumeric': 0.13855970829535097, 'fraction_numerical': 0.01959890610756609, 'mean_word_length': 1.4574468085106382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '3676200', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1209, 'n_words': 271}