cqfn / veniq

Veniq uses Machine Learning to analyze source code, find possible refactorings, and suggest those that seem optimal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SEMI: convenient API for EMO recommendation

KatGarmash opened this issue · comments

EMO = Extract Method Opportunity

Why

Currently, there is no implemented function that takes a method source code and directly output EMO recommendations. Such functionality could be useful to the end-used or if called by some refactoring plugin.

What we want

A function that takes a method declaration, and outputs SEMI recommendation in the form of an ordered list of recommended EMOs. The order is of decreasing recommendation. EMO is represented as a tuple (start_line_number, end_line_number).

def recommend(method_declaration_lines: List[str]): -> List[(int, int)]

Proposed solution

  • Write a wrapper around existing functions extract_method_statements_semantic, create_extraction_opportunities,
    filter_extraction_opportunities, rank_extraction_opportunities
  • implement it in a separate file under veniq.baseline.semi

@acheshkov @lyriccoder discuss

commented

@KatGarmash it's clear to me