| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.integration.analysis.lint; |
| 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 |
| 11 import '../../utils.dart'; |
| 12 import '../integration_tests.dart'; |
| 13 |
| 14 main() { |
| 15 initializeTestEnvironment(); |
| 16 defineReflectiveTests(LintIntegrationTest); |
| 17 } |
| 18 |
| 19 @reflectiveTest |
| 20 class LintIntegrationTest extends AbstractAnalysisServerIntegrationTest { |
| 21 test_no_lints_when_not_specified() async { |
| 22 String source = sourcePath('test.dart'); |
| 23 writeFile( |
| 24 source, |
| 25 ''' |
| 26 class abc { // lint: not CamelCase (should get ignored though) |
| 27 }'''); |
| 28 standardAnalysisSetup(); |
| 29 |
| 30 await analysisFinished; |
| 31 expect(currentAnalysisErrors[source], isList); |
| 32 // Should be empty without .analysis_options. |
| 33 List<AnalysisError> errors = currentAnalysisErrors[source]; |
| 34 expect(errors, hasLength(0)); |
| 35 } |
| 36 |
| 37 test_simple_lint() async { |
| 38 writeFile( |
| 39 sourcePath('.analysis_options'), |
| 40 ''' |
| 41 linter: |
| 42 rules: |
| 43 - camel_case_types |
| 44 '''); |
| 45 |
| 46 String source = sourcePath('test.dart'); |
| 47 writeFile( |
| 48 source, |
| 49 ''' |
| 50 class a { // lint: not CamelCase |
| 51 }'''); |
| 52 |
| 53 standardAnalysisSetup(); |
| 54 |
| 55 await analysisFinished; |
| 56 |
| 57 expect(currentAnalysisErrors[source], isList); |
| 58 List<AnalysisError> errors = currentAnalysisErrors[source]; |
| 59 expect(errors, hasLength(1)); |
| 60 AnalysisError error = errors[0]; |
| 61 expect(error.location.file, source); |
| 62 expect(error.severity, AnalysisErrorSeverity.INFO); |
| 63 expect(error.type, AnalysisErrorType.LINT); |
| 64 } |
| 65 } |
| OLD | NEW |