cqfn / aibolit

Static Analyzer for Java Code with Machine Learning in Mind
https://pypi.org/project/aibolit/
51 stars 17 forks source link

Refactor nested blocks. #578

Closed aravij closed 4 years ago

aravij commented 4 years ago

Delete nested loops and use nested blocks pattern drectly.

aravij commented 4 years ago

There is one test failing. Are we considering a pattern with nested if like this:

if(x == 0) {
    doSmth();
    if(y == 0) {
        doSmth();
    }
    doSmth();
}

It does seems to me a direct nesting like in all other test examples with cycles.

acheshkov commented 4 years ago

@rultor merge

rultor commented 4 years ago

@rultor merge

@acheshkov OK, I'll try to merge now. You can check the progress of the merge here

rultor commented 4 years ago

@rultor merge

@acheshkov @aravij Oops, I failed. You can see the full log here (spent 2min)

+ cat
+ '[' false = true ']'
+ cat
+ chmod a+x entry.sh
+ cat
+ echo 'export '\''head=git@github.com:cqfn/aibolit.git'\''' ';' 'export '\''pull_id=578'\''' ';' 'export '\''fork=git@github.com:cqfn/aibolit.git'\''' ';' 'export '\''fork_branch=issue-528_5'\''' ';' 'export '\''head_branch=master'\''' ';' 'export '\''pull_title=Refactor nested blocks.'\''' ';' 'export '\''author=acheshkov'\''' ';' 'python3 -m pip install twine' ';' make ';'
+ sensitive=()
+ rm -rf .gpg
+ cd repo
+ git remote add fork git@github.com:cqfn/aibolit.git
+ git remote update
Fetching origin
Fetching fork
From github.com:cqfn/aibolit
 * [new branch]      acheshkov-patch-1 -> fork/acheshkov-patch-1
 * [new branch]      acheshkov-patch-2 -> fork/acheshkov-patch-2
 * [new branch]      acheshkov-scope-update -> fork/acheshkov-scope-update
 * [new branch]      issue-295  -> fork/issue-295
 * [new branch]      issue-310  -> fork/issue-310
 * [new branch]      issue-404  -> fork/issue-404
 * [new branch]      issue-418  -> fork/issue-418
 * [new branch]      issue-419  -> fork/issue-419
 * [new branch]      issue-528_5 -> fork/issue-528_5
 * [new branch]      issue-532  -> fork/issue-532
 * [new branch]      issue-533  -> fork/issue-533
 * [new branch]      issue-535  -> fork/issue-535
 * [new branch]      issue-537  -> fork/issue-537
 * [new branch]      issue-538  -> fork/issue-538
 * [new branch]      issue-550  -> fork/issue-550
 * [new branch]      issue_528_1 -> fork/issue_528_1
 * [new branch]      issue_528_10 -> fork/issue_528_10
 * [new branch]      issue_528_11 -> fork/issue_528_11
 * [new branch]      issue_528_15 -> fork/issue_528_15
 * [new branch]      issue_528_18 -> fork/issue_528_18
 * [new branch]      issue_528_3 -> fork/issue_528_3
 * [new branch]      issue_528_7 -> fork/issue_528_7
 * [new branch]      issue_528_8 -> fork/issue_528_8
 * [new branch]      java_files_custom_dir -> fork/java_files_custom_dir
 * [new branch]      master     -> fork/master
 * [new branch]      style      -> fork/style
 * [new branch]      taks-258   -> fork/taks-258
 * [new branch]      task-258   -> fork/task-258
 * [new branch]      upstream/java_files_custom_dir -> fork/upstream/java_files_custom_dir
 * [new branch]      wp_update  -> fork/wp_update
+ args=
+ '[' default == default ']'
+ args=' --ff'
+ '[' default == no ']'
+ '[' default == only ']'
+ export BRANCH=__rultor
+ BRANCH=__rultor
++ git show-branch __rultor
++ wc -l
+ '[' 0 -gt 0 ']'
+ git checkout -B __rultor fork/issue-528_5
error: Your local changes to the following files would be overwritten by checkout:
    wp/how_it_works_diagram_5.jpg
Please, commit your changes or stash them before you can switch branches.
Aborting
'cid' file is absent, container wasn't started correctly
acheshkov commented 4 years ago

@aravij please take a look

aravij commented 4 years ago

@acheshkov The merge will fail anyway, because unit tests are failing. I posted above a comment about current pattern. How does this pattern should behave? I can't extract this information from comments. There is only one such example. is it correct or not?

acheshkov commented 4 years ago

@acheshkov The merge will fail anyway, because unit tests are failing. I posted above a comment about current pattern. How does this pattern should behave? I can't extract this information from comments. There is only one such example. is it correct or not?

@aravij Sorry, did not realize that it's a question.

acheshkov commented 4 years ago

There is one test failing. Are we considering a pattern with nested if like this:

if(x == 0) {
    doSmth();
    if(y == 0) {
        doSmth();
    }
    doSmth();
}

It does seems to me a direct nesting like in all other test examples with cycles.

@aravij Yes, let's consider this as a pattern match

aravij commented 4 years ago

@acheshkov tests are fixed. Please approve and merge.

acheshkov commented 4 years ago

@rultor merge

rultor commented 4 years ago

@rultor merge

@acheshkov OK, I'll try to merge now. You can check the progress of the merge here

rultor commented 4 years ago

@rultor merge

@acheshkov Done! FYI, the full log is here (took me 41min)