Skip to content

Commit

Permalink
Move max suggestions count to const (#4249)
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop authored and hudochenkov committed Sep 4, 2019
1 parent b1285f1 commit 8f366c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/reportUnknownRuleNames.js
Expand Up @@ -4,6 +4,7 @@ const levenshteinDistance = require("./utils/levenshteinDistance");
const rules = require("./rules");

const MAX_LEVENSHTEIN_DISTANCE = 6;
const MAX_SUGGESTIONS_COUNT = 3;

function extractSuggestions(ruleName) {
const suggestions = new Array(MAX_LEVENSHTEIN_DISTANCE);
Expand All @@ -29,14 +30,14 @@ function extractSuggestions(ruleName) {
for (let i = 0; i < suggestions.length; i++) {
if (suggestions[i].length > 0) {
if (i < 3) {
return suggestions[i].slice(0, 3);
return suggestions[i].slice(0, MAX_SUGGESTIONS_COUNT);
}

result = result.concat(suggestions[i]);
}
}

return result.slice(0, 3);
return result.slice(0, MAX_SUGGESTIONS_COUNT);
}

function rejectMessage(ruleName, suggestions = []) {
Expand Down

0 comments on commit 8f366c9

Please sign in to comment.