Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ограничить цикломатическую сложность функций #203

Closed
m1kc opened this issue Sep 14, 2013 · 1 comment

Comments

@m1kc
Copy link
Member

m1kc commented Sep 14, 2013

В JSHint есть опция maxcomplexity, заставляющая его ругаться на слишком сложные функции. В большинстве случаев сложные функции действительно лучше разбивать на несколько мелких.

Непонятно только одно: какую цикломатическую сложность считать приемлемой. Сейчас у нас одна функция со сложностью 5 (та, которая общается с РНР), а остальные - не сложнее 2. Но статистики пока мало, поэтому откладываю задачу на будущее.

@m1kc m1kc closed this as completed in c489706 Nov 23, 2013
@m1kc
Copy link
Member Author

m1kc commented Nov 23, 2013

Выставил пока 10. Чую, что надо ещё меньше, но пусть пока так.

Немного статистики:

Linting cgi.js ...ERROR
[L40:C17] W074: This function's cyclomatic complexity is too high. (5)
function phpgate(request, response)
Linting utils/game.js ...ERROR
[L26:C18] W074: This function's cyclomatic complexity is too high. (4)
    function (error, result) {
Linting utils/game.js ...ERROR
[L59:C18] W074: This function's cyclomatic complexity is too high. (4)
    function (error, result) {
Linting utils/game.js ...ERROR
[L101:C59] W074: This function's cyclomatic complexity is too high. (5)
  exports.getUserLocation(dbConnection, userid, function(error, result) {
Linting utils/game.js ...ERROR
[L156:C17] W074: This function's cyclomatic complexity is too high. (4)
    function(error, result) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant