diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3ca83fe..5585226f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.1.23 + +* Removed `whitespace_around_ops` pending re-name and re-design (#249). + + # 0.1.22 * Grinder support (`rule:rule_name` and `docs:location`) for rule stub and doc generation (respectively). diff --git a/lib/src/rules.dart b/lib/src/rules.dart index e36524a63..3496252aa 100644 --- a/lib/src/rules.dart +++ b/lib/src/rules.dart @@ -53,7 +53,6 @@ import 'package:linter/src/rules/unnecessary_brace_in_string_interp.dart'; import 'package:linter/src/rules/unnecessary_getters_setters.dart'; import 'package:linter/src/rules/unrelated_type_equality_checks.dart'; import 'package:linter/src/rules/valid_regexps.dart'; -import 'package:linter/src/rules/whitespace_around_ops.dart'; final Registry ruleRegistry = new Registry() ..register(new AlwaysDeclareReturnTypes()) @@ -102,8 +101,7 @@ final Registry ruleRegistry = new Registry() //..register(new UnnecessaryGetters()) ..register(new UnnecessaryGettersSetters()) ..register(new UnrelatedTypeEqualityChecks()) - ..register(new ValidRegExps()) - ..register(new WhitespaceAroundOps()); + ..register(new ValidRegExps()); /// Registry of contributed lint rules. class Registry extends Object with IterableMixin { diff --git a/lib/src/rules/whitespace_around_ops.dart b/lib/src/rules/whitespace_around_ops.dart deleted file mode 100644 index 38ae5ca7b..000000000 --- a/lib/src/rules/whitespace_around_ops.dart +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library linter.src.rules.whitespace_around_ops; - -import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/ast/token.dart'; -import 'package:analyzer/dart/ast/visitor.dart'; -import 'package:linter/src/linter.dart'; - -const desc = r'Use proper whitespace around operators.'; - -const details = r''' -**DO** ensure that there are spaces around binary operators and before any -unary ones. - -Improper whitespace can create confusion, especially when applied to operators -where it's possible to get a binary operator when you mean a unary one. For -example, the mistyping of `5 /~ 10` when you mean `5 ~/ 10` is hidden by the -improper spacing. (Properly spaced, the mistake is more clear: `5 / ~10`.) -Whenever possible, use the formatter to cleanup whitespace. Otherwise, take -care to ensure that there are spaces around binary operators and before any -unary ones. - - -**BAD:** -``` -print(5 /~ 10); //whoops -``` - -**GOOD:** -``` -print(5 / ~10); //aha! -``` -'''; - -class Visitor extends SimpleAstVisitor { - final LintRule rule; - Visitor(this.rule); - - @override - visitBinaryExpression(BinaryExpression node) { - if (!spaced(node.leftOperand.endToken, node.operator) || - !spaced(node.operator, node.rightOperand.beginToken)) { - rule.reportLintForToken(node.operator); - } - } - - @override - visitPrefixExpression(PrefixExpression node) { - if (spaced(node.operator, node.operand.beginToken)) { - rule.reportLintForToken(node.operator); - } - } - - static bool spaced(Token first, Token second) => - first != null && second != null && first.end != second.offset; -} - -class WhitespaceAroundOps extends LintRule { - WhitespaceAroundOps() - : super( - name: 'whitespace_around_ops', - description: desc, - details: details, - group: Group.style); - - @override - AstVisitor getVisitor() => new Visitor(this); -} diff --git a/pubspec.yaml b/pubspec.yaml index 8934c66f5..5e18cfa94 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: linter -version: 0.1.22 +version: 0.1.23 author: Dart Team description: Style linter for Dart. homepage: https://github.com/dart-lang/linter diff --git a/test/rules/whitespace_around_ops.dart b/test/rules/whitespace_around_ops.dart deleted file mode 100644 index c7346d623..000000000 --- a/test/rules/whitespace_around_ops.dart +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// test w/ `dart test/util/solo_test.dart whitespace_around_ops` - - -// Define our own int so we don't need `int` in our mock SDK. -class MyInt { - MyInt operator -() => this; - MyInt operator ~() => this; - MyInt operator ~/(MyInt other) => this; - MyInt operator /(MyInt other) => this; -} - -void main() { - MyInt f, g; - print(f ~/ g); - print(f~/ g); //LINT - print(f ~/g); //LINT - print(f~/g); //LINT - print(f/ ~g); //LINT - print(f /~g); //LINT - print(f / ~g); //OK - f =- g; //LINT - f = -g; //OK -}