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

Bonobo for Ekaterina Draft Dirty #128

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Bonobo for Ekaterina Draft Dirty #128

wants to merge 8 commits into from

Conversation

lyriccoder
Copy link
Member

Bonobo for Ekaterina Draft Dirty

@lyriccoder lyriccoder marked this pull request as draft February 9, 2021 13:30
@KatGarmash
Copy link
Member

@lyriccoder can you please remove unused (commented) code and make the PR "clean"?

Copy link
Member

@KatGarmash KatGarmash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you commit just the high-level graph? and remove commented code?

@lyriccoder
Copy link
Member Author

I am doing it right now

@lyriccoder
Copy link
Member Author

@KatGarmash done, we can discuss it

return {'input_dir': str(input_dir), 'output_dir': str(output_dir)}


def pass_params_to_next_node(dirs_dict, em_item: Dict[Tuple, Tuple]):
Copy link
Member

@KatGarmash KatGarmash Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u come up with a more informative name of the method please?

return {'input_dir': str(input_dir), 'output_dir': str(output_dir)}


def pass_params_to_next_node(dirs_dict, em_item: Dict[Tuple, Tuple]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

come up with a custom type for the contents of the em_item dictionary? it's hard to interpret otw

return {'input_dir': str(input_dir), 'output_dir': str(output_dir)}


def pass_params_to_next_node(dirs_dict, em_item: Dict[Tuple, Tuple]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dirs_dict type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return type?

from bonobo.config import Exclusive


def aggregate(dirs, dct):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u come up with a more informative name of the method, and also type-annotate it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this methid do?

@@ -0,0 +1,128 @@
digraph {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep it? If we loose it, Egor will be disappointed. Managers need pictures

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think he meant such a graph

ASTNodeType.METHOD_INVOCATION):
extracted_m_decl = method_declarations.get(method_invoked.member, [])
if len(extracted_m_decl) == 1:
t = tuple([input_filename, class_declaration.name, method_invoked.line])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd come up with a custom class to store the data in the keys and the values

directory.mkdir(parents=True)


def preprocess(file: str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each node returns a dict

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so please specify that, including the contents of the dict

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ugly, I've done this. 'Cause it can have any value -> Dict[str, Any] doesn't tell you smth important

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that s why i asked to come up with custom types

Copy link
Member

@KatGarmash KatGarmash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see inline comments


maybe_if = parent.parent
is_not_method_inv_single_statement_in_if = True
if maybe_if.node_type == ASTNodeType.IF_STATEMENT:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if blabla
inv()

if total_return_statements > 0:
is_not_several_returns = False

has_not_throw = len([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where throw is last element

func() {
if () {
}
throw Exception();
}

func() {
if () {
throw Exception();
}
}

has_not_throw = len([
x for x in extracted_m_decl.body
if x.node_type == ASTNodeType.THROW_STATEMENT]) < 1
is_not_parent_member_ref = not (method_invoked.parent.node_type == ASTNodeType.MEMBER_REFERENCE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

x for x in extracted_m_decl.body
if x.node_type == ASTNodeType.THROW_STATEMENT]) < 1
is_not_parent_member_ref = not (method_invoked.parent.node_type == ASTNodeType.MEMBER_REFERENCE)
is_not_chain_before = not (parent.node_type == ASTNodeType.METHOD_INVOCATION) and no_children
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chaijn().func()

if x.node_type == ASTNodeType.THROW_STATEMENT]) < 1
is_not_parent_member_ref = not (method_invoked.parent.node_type == ASTNodeType.MEMBER_REFERENCE)
is_not_chain_before = not (parent.node_type == ASTNodeType.METHOD_INVOCATION) and no_children
chains_after = [x for x in method_invoked.children if x.node_type == ASTNodeType.METHOD_INVOCATION]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func().chain()

is_not_chain_before = not (parent.node_type == ASTNodeType.METHOD_INVOCATION) and no_children
chains_after = [x for x in method_invoked.children if x.node_type == ASTNodeType.METHOD_INVOCATION]
is_not_chain_after = not chains_after
is_not_inside_if = not (parent.node_type == ASTNodeType.IF_STATEMENT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably special case

is_not_ternary = not (parent.node_type == ASTNodeType.TERNARY_EXPRESSION)
# if a parameter is any expression, we ignore it,
# since it is difficult to extract with AST
is_actual_parameter_simple = all([hasattr(x, 'member') for x in method_invoked.arguments])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there s no expression among parameters

# if a parameter is any expression, we ignore it,
# since it is difficult to extract with AST
is_actual_parameter_simple = all([hasattr(x, 'member') for x in method_invoked.arguments])
is_not_actual_param_cast = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether some param has a type cast

if len(found_casts) > 0:
is_not_actual_param_cast = False

is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Constr(method())

is_not_actual_param_cast = False

is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR)
is_not_cast_of_return_type = not (parent.node_type == ASTNodeType.CAST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a = (int) func()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func((a)a)


is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR)
is_not_cast_of_return_type = not (parent.node_type == ASTNodeType.CAST)
is_not_array_creator = not (parent.node_type == ASTNodeType.ARRAY_CREATOR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new int [func()]

is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR)
is_not_cast_of_return_type = not (parent.node_type == ASTNodeType.CAST)
is_not_array_creator = not (parent.node_type == ASTNodeType.ARRAY_CREATOR)
is_not_lambda = not (parent.node_type == ASTNodeType.LAMBDA_EXPRESSION)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inside lambda expression

is_not_lambda = not (parent.node_type == ASTNodeType.LAMBDA_EXPRESSION)
is_not_at_the_same_line_as_prohibited_stats = check_nesting_statements(method_invoked)

are_functional_arguments_eq = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

names of passed arguments equal to names of parameters in the definition

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