Remove nullability from naming conventions.
We don't allow nulls there anymore.
Change-Id: I44639fee24bbd3856798ae15739b70cc0c660b25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196045
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart b/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
index 79bf48c..678166f 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
@@ -19,8 +19,8 @@
/// - OK if the name is valid;
/// - WARNING if the name is discouraged;
/// - FATAL if the name is illegal.
-RefactoringStatus validateConstructorName(String? name) {
- if (name != null && name.isEmpty) {
+RefactoringStatus validateConstructorName(String name) {
+ if (name.isEmpty) {
return RefactoringStatus();
}
return _validateLowerCamelCase(name, 'Constructor', allowBuiltIn: true);
@@ -46,8 +46,8 @@
/// - OK if the name is valid;
/// - WARNING if the name is discouraged;
/// - FATAL if the name is illegal.
-RefactoringStatus validateImportPrefixName(String? name) {
- if (name != null && name.isEmpty) {
+RefactoringStatus validateImportPrefixName(String name) {
+ if (name.isEmpty) {
return RefactoringStatus();
}
return _validateLowerCamelCase(name, 'Import prefix');
@@ -65,11 +65,7 @@
/// - OK if the name is valid;
/// - WARNING if the name is discouraged;
/// - FATAL if the name is illegal.
-RefactoringStatus validateLibraryName(String? name) {
- // null
- if (name == null) {
- return RefactoringStatus.fatal('Library name must not be null.');
- }
+RefactoringStatus validateLibraryName(String name) {
// blank
if (isBlank(name)) {
return RefactoringStatus.fatal('Library name must not be blank.');
@@ -180,14 +176,9 @@
}
/// Validates [identifier], should be lower camel case.
-RefactoringStatus _validateLowerCamelCase(String? identifier, String desc,
+RefactoringStatus _validateLowerCamelCase(String identifier, String desc,
{bool allowBuiltIn = false}) {
desc += ' name';
- // null
- if (identifier == null) {
- var message = '$desc must not be null.';
- return RefactoringStatus.fatal(message);
- }
// is not identifier
var status = _validateIdentifier(
identifier, desc, 'a lowercase letter or underscore',
@@ -213,13 +204,8 @@
}
/// Validate the given identifier, which should be upper camel case.
-RefactoringStatus _validateUpperCamelCase(String? identifier, String desc) {
+RefactoringStatus _validateUpperCamelCase(String identifier, String desc) {
desc += ' name';
- // null
- if (identifier == null) {
- var message = '$desc must not be null.';
- return RefactoringStatus.fatal(message);
- }
// is not identifier
var status = _validateIdentifier(
identifier, desc, 'an uppercase letter or underscore');
diff --git a/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart b/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart
index 8441368..50ccb48 100644
--- a/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart
@@ -111,12 +111,6 @@
'Constructor name must begin with a lowercase letter or underscore.');
}
- void test_validateConstructorName_null() {
- assertRefactoringStatus(
- validateConstructorName(null), RefactoringProblemSeverity.FATAL,
- expectedMessage: 'Constructor name must not be null.');
- }
-
void test_validateConstructorName_OK() {
assertRefactoringStatusOK(validateConstructorName('newName'));
}
@@ -287,12 +281,6 @@
'Import prefix name must begin with a lowercase letter or underscore.');
}
- void test_validateImportPrefixName_null() {
- assertRefactoringStatus(
- validateImportPrefixName(null), RefactoringProblemSeverity.FATAL,
- expectedMessage: 'Import prefix name must not be null.');
- }
-
void test_validateImportPrefixName_OK() {
assertRefactoringStatusOK(validateImportPrefixName('newName'));
}
@@ -433,12 +421,6 @@
'Library name identifier must begin with a lowercase letter or underscore.');
}
- void test_validateLibraryName_null() {
- assertRefactoringStatus(
- validateLibraryName(null), RefactoringProblemSeverity.FATAL,
- expectedMessage: 'Library name must not be null.');
- }
-
void test_validateLibraryName_OK_oneIdentifier() {
assertRefactoringStatusOK(validateLibraryName('name'));
}