<commit_before>import { RuleTester, Failure, Position } from './ruleTester';

const ruleTester = new RuleTester('space-in-parens');
const MISSING_SPACE_ERROR = 'there must be a space inside this paren.';
const REJECTED_SPACE_ERROR = 'there should be no spaces inside this paren.';

function expecting(errors): Failure[] {
  return errors.map((err) => {
    if (err.message && err.column) {
      return {
        failure: err.message,
        startPosition: new Position(err.line, err.column),
        endPosition: new Position(err.line, err.column)
      };
    }
  });
}

ruleTester.addTestGroup('valid', 'should pass valid', [
  { code: 'foo()', options: ['always'] },
  { code: 'foo\n(\nbar\n)\n', options: ['always'] },
  { code: 'foo\n(  \nbar\n )\n', options: ['always'] },
  { code: 'foo\n(\n bar  \n)\n', options: ['always'] },
  { code: 'foo\n( \n  bar \n  )\n', options: ['always'] },
  { code: 'foo\n(\t\nbar\n)', options: ['always'] },
  { code: '\tfoo(\n\t\tbar\n\t)', options: ['always'] },
  { code: '\tfoo\n(\t\n\t\tbar\t\n\t)', options: ['always'] },
  { code: 'var x = ( 1 + 2 ) * 3', options: ['always'] },
  { code: 'var x = `foo(bar)`', options: ['always'] },
  { code: 'var x = "bar( baz )"', options: ['always'] },
  { code: 'var foo = `(bar)`;', options: ['always'] },
  { code: 'var foo = `(bar ${baz})`;', options: ['always'] },
  { code: 'var foo = `(bar ${( 1 + 2 )})`;', options: ['always'] },
  { code: 'bar()', options: ['never'] },
  { code: 'bar(baz)', options: ['never'] },
  { code: 'var x = (4 + 5) * 6', options: ['never'] },
  { code: 'foo\n(\nbar\n)\n', options: ['never'] },
  { code: 'foo\n(  \nbar\n )\n', options: ['never'] },
  { code: 'foo\n(\n bar  \n)\n', options: ['never'] },
  { code: 'foo\n( \n  bar \n  )\n', options: ['never'] },
  { code: 'var foo = `( bar )`;', options: ['never'] },
  { code: 'var foo = `( bar ${baz} )`;', options: ['never'] },
  { code: 'var foo = `(bar ${(1 + 2)})`;', options: ['never'] },
  { code: 'new MyClass( somethimg )', options: ['always'] },

  // classes
  { code: 'class Test { foo( bar:string, asdsd:number, asd:any ) : void {} }', options: ['always'] },
  { code: 'class Test { foo(bar:string, asdsd:number, asd:any) : void {} }', options: ['never'] },
  { code: 'class Test { protected foo( bar:string, asdsd:number, asd:any ) : void {} }', options: ['always'] },
  { code: 'class Test { protected foo(bar:string, asdsd:number, asd:any) : void {} }', options: ['never'] },

  // functions
  { code: 'function foo( bar:string, asdsd:number, asd:any ) : void {}', options: ['always'] },
  { code: 'function foo(bar:string, asdsd:number, asd:any) : void {}', options: ['never'] },
  { code: 'function ( bar:string, asdsd:number, asd:any ) : void {}', options: ['always'] },
  { code: 'function (bar:string, asdsd:number, asd:any) : void {}', options: ['never'] },

  // constructors
  { code: 'constructor( bar:string, asdsd:number, asd:any ){}', options: ['always'] },
  { code: 'constructor(bar:string, asdsd:number, asd:any){}', options: ['never'] },

  // exceptions
  { code: 'foo({ bar: "baz" })', options: ['always', { exceptions: ['{}'] }] },
  { code: 'foo( { bar: "baz" } )', options: ['always', { exceptions: ['[]', '()'] }] },
  { code: 'foo( 1, { bar: "baz" })', options: ['always', { exceptions: ['{}'] }] },
  { code: 'foo({ bar: "baz" }, 1 )', options: ['always', { exceptions: ['{}'] }] },<commit_msg>Add rules to check for loops<commit_after>import { RuleTester, Failure, Position } from './ruleTester';

const ruleTester = new RuleTester('space-in-parens');
const MISSING_SPACE_ERROR = 'there must be a space inside this paren.';
const REJECTED_SPACE_ERROR = 'there should be no spaces inside this paren.';

function expecting(errors): Failure[] {
  return errors.map((err) => {
    if (err.message && err.column) {
      return {
        failure: err.message,
        startPosition: new Position(err.line, err.column),
        endPosition: new Position(err.line, err.column)
      };
    }
  });
}

ruleTester.addTestGroup('valid', 'should pass valid', [
  { code: 'foo()', options: ['always'] },
  { code: 'foo\n(\nbar\n)\n', options: ['always'] },
  { code: 'foo\n(  \nbar\n )\n', options: ['always'] },
  { code: 'foo\n(\n bar  \n)\n', options: ['always'] },
  { code: 'foo\n( \n  bar \n  )\n', options: ['always'] },
  { code: 'foo\n(\t\nbar\n)', options: ['always'] },
  { code: '\tfoo(\n\t\tbar\n\t)', options: ['always'] },
  { code: '\tfoo\n(\t\n\t\tbar\t\n\t)', options: ['always'] },
  { code: 'var x = ( 1 + 2 ) * 3', options: ['always'] },
  { code: 'var x = `foo(bar)`', options: ['always'] },
  { code: 'var x = "bar( baz )"', options: ['always'] },
  { code: 'var foo = `(bar)`;', options: ['always'] },
  { code: 'var foo = `(bar ${baz})`;', options: ['always'] },
  { code: 'var foo = `(bar ${( 1 + 2 )})`;', options: ['always'] },
  { code: 'bar()', options: ['never'] },
  { code: 'bar(baz)', options: ['never'] },
  { code: 'var x = (4 + 5) * 6', options: ['never'] },
  { code: 'foo\n(\nbar\n)\n', options: ['never'] },
  { code: 'foo\n(  \nbar\n )\n', options: ['never'] },
  { code: 'foo\n(\n bar  \n)\n', options: ['never'] },
  { code: 'foo\n( \n  bar \n  )\n', options: ['never'] },
  { code: 'var foo = `( bar )`;', options: ['never'] },
  { code: 'var foo = `( bar ${baz} )`;', options: ['never'] },
  { code: 'var foo = `(bar ${(1 + 2)})`;', options: ['never'] },
  { code: 'new MyClass( somethimg )', options: ['always'] },

  // conditions/loops
  { code: 'if ( true ) {}', options: ['always'] },
  { code: 'if (true) {}', options: ['never'] },
  { code: 'while ( true ) {}', options: ['always'] },
  { code: 'while (true) {}', options: ['never'] },
  { code: 'for ( let i=0; i<100; i++ ) {}', options: ['always'] },
  { code: 'for (let i=0; i<100; i++) {}', options: ['never'] },
  { code: 'for ( let i in foo ) {}', options: ['always'] },
  { code: 'for (let i in foo) {}', options: ['never'] },
  { code: 'for ( let i of foo ) {}', options: ['always'] },
  { code: 'for (let i of foo) {}', options: ['never'] },

  // classes
  { code: 'class Test { foo( bar:string, asdsd:number, asd:any ) : void {} }', options: ['always'] },
  { code: 'class Test { foo(bar:string, asdsd:number, asd:any) : void {} }', options: ['never'] },
  { code: 'class Test { protected foo( bar:string, asdsd:number, asd:any ) : void {} }', options: ['always'] },
  { code: 'class Test { protected foo(bar:string, asdsd:number, asd:any) : void {} }', options: ['never'] },

  // functions
  { code: 'function foo( bar:string, asdsd:number, asd:any ) : void {}', options: ['always'] },
  { code: 'function foo(bar:string, asdsd:number, asd:any) : void {}', options: ['never'] },
  { code: 'function ( bar:string, asdsd:number, asd:any ) : void {}', options: ['always'] },
  { code: 'function (bar:string, asdsd:number, asd:any) : void {}', options: ['never'] },

  // constructors
  { code: 'constructor( bar:string, asdsd:number, asd:any ){}', options: ['always'] },
  { code: 'constructor(bar:string, asdsd:number, asd:any){}', options: ['never'] },

  // exceptions
  { code: 'foo({ bar: "baz" })', options: ['always', { exceptions: ['{}'] }] },
  { code: 'foo( { bar: "baz" } )', options: ['always', { exceptions: ['[]', '()'] }] },
  { code: 'foo( 1, { bar: "baz" })', options: ['always', { exceptions: ['{}'] }] },
  { code: 'foo({ bar: "baz" }, 1 )', options: ['always', { exceptions: ['{}'] }] },
{'fraction_non_alphanumeric': 0.2647891119795176, 'fraction_numerical': 0.004312087319768225, 'mean_word_length': 3.69746835443038, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5818545', 'n_tokens_mistral': 2815, 'n_tokens_neox': 2757, 'n_words': 718}