Skip to content

Conversation

@IvanChumakov
Copy link

Made some changes in slugify function using the Radon utility (reduce the cyclomatic complexity of the function)

@marksteward
Copy link
Contributor

This is probably worth doing, but it could do with some tidy-up.

In particular:

  • the docstring has vanished
  • _ensure_unicode is redundant since python3
  • _truncate_text takes default_separator instead of referring to the global DEFAULT_SEPARATOR
  • _adjust_separator takes both default_separator and separator
  • _apply_replacements, _adjust_case, _process_stopwords and _adjust_separator all do an early return if not enabled on entry. This would be clearer outside the functions, and shows that _adjust_case really just obscures a call to .lower().

I also think _safe_sub should be wrapping repl, not re.sub, but this would be a change in behaviour.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants