← Back to all posts

December 18, 2020

Sourcery Pro launched

You can now purchase a Sourcery Pro subscription.

With Sourcery Pro you can:

  • Remove duplicate code with our new automated method extraction
  • Refactor your whole project in the IDE
  • Use our GitHub bot on private repos
  • Find duplicate code across your project (VS Code only at present)

Get more details here.

Duplicate code detection

You can now select multiple files or folders and scan for duplicated code within them. This will find sections of code that are 3 lines long or greater that are duplicated in multiple places. It will also find near-duplicate code where variable names have been changed but the code structure remains the same.

This feature is available in our Pro subscription, for VS Code users only initially. It is in active development so we would love your feedback.

Duplicate code detection
Scan for duplicate code in VS Code

Sublime support

Sourcery is now available in Sublime.

Get more details and setup instructions here.

New refactorings

Use str.join() instead of for loop: use-join

This will convert code like this:

result = ""
for text in long_list_of_text():
    result = result + text
return result


result = "".join(long_list_of_text())
return result

Simplify Constant Sum: simplify-constant-sum

Changes this:

results = sum(1 for token in source.split() if token == 1)

to this:

results = sum(token == 1 for token in source.split())

Minor fixes

  • Make simplify-boolean-comparison suggest more often
  • use-count now triggers on the result of simplify-constant-sum rather than directly
  • remove-redundant-if now slightly more powerful
  • Improved handling of if..elif chains with repeated code
  • Don't remove-redundant-if when invalidated by a context manager
  • Fix issue where switch refactoring could produce incorrect result
  • Fix issue with hoisting statements from loops which could produce incorrect results
  • Fixed issue in PyCharm where Sourcery could lose connection to binary when it was scanning a very large function.