Skip to content

Commit

Permalink
- Fixed mr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DerhachevAndrii committed Mar 13, 2024
1 parent a5d7936 commit f9686f2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,9 @@ class FunctionLinesOfCodeMetric
ErrorReporter reporter,
AstNode node,
) {
final name = () {
if (node is FunctionDeclaration) {
return node.name.lexeme;
} else if (node is MethodDeclaration) {
return node.name.lexeme;
} else if (node is FunctionExpression) {
return node.declaredElement?.name;
} else {
return null;
}
}();

if (name != null && config.parameters.excludeNames.contains(name)) {
final functionName = _getFunctionName(node);
if (functionName != null &&
config.parameters.excludeNames.contains(functionName)) {
return;
}

Expand All @@ -94,4 +84,16 @@ class FunctionLinesOfCodeMetric
);
}
}

String? _getFunctionName(AstNode node) {
if (node is FunctionDeclaration) {
return node.name.lexeme;
} else if (node is MethodDeclaration) {
return node.name.lexeme;
} else if (node is FunctionExpression) {
return node.declaredElement?.name;
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class FunctionLinesOfCodeParameters {
/// exceeding this limit triggers a warning.
final int maxLines;

/// Method names to be excluded from the rule check
/// Function names to be excluded from the rule check
final List<String> excludeNames;

static const _defaultMaxLines = 200;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class ClassWithLongMethods {
int notLongMethod() {
var i = 0;
i++;
i++;
i++;
return i;
}

// expect_lint: function_lines_of_code
int longMethod() {
var i = 0;
Expand All @@ -20,6 +28,14 @@ class ClassWithLongMethods {
}
}

int notLongFunction() {
var i = 0;
i++;
i++;
i++;
return i;
}

// expect_lint: function_lines_of_code
int longFunction() {
var i = 0;
Expand Down

0 comments on commit f9686f2

Please sign in to comment.