Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Unified Diff: lib/src/rules/whitespace_around_ops.dart

Issue 2189993002: Remove `whitespace_around_ops` pending re-name and re-design (#249). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/rules.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/rules/whitespace_around_ops.dart
diff --git a/lib/src/rules/whitespace_around_ops.dart b/lib/src/rules/whitespace_around_ops.dart
deleted file mode 100644
index 38ae5ca7b203c316424c95856a1a56d03d774504..0000000000000000000000000000000000000000
--- 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);
-}
« no previous file with comments | « lib/src/rules.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698