nvbn / thefuck

Magnificent app which corrects your previous console command.
MIT License
85.08k stars 3.43k forks source link

Handling of simple compilation errors #320

Open SylvainDe opened 9 years ago

SylvainDe commented 9 years ago

Hi I know this is pretty far-fetched and out of this project scope but I just got this error while compiling my code Tests_Feature/my_test_file.cpp:1925:2: error: expected ';' before 'MyClassName' and thought "FUCK". Then I just opened the file, went to line 1925 and inserted a ';' before "MyClassName" *. I think this error contains enough information for some automatic processing to fix the issue and I'd like to give it a try when I have a bit of spare time.

mcarton commented 9 years ago

Maybe running $EDITOR Tests_Feature/my_test_file.cpp +1925 && the_previous_command would be enough? (I'm actually surprised the +line thing works with vi, vim, nano and emacs).

scorphus commented 9 years ago

In the meantime – while TheFuck still makes no amendments in source code files – it's fair enough to open the file in the user's preferred editor.

mcarton commented 9 years ago

I'll implement that tomorrow. I started to list some patterns:

pattern tools note
^awk: {file}:{line}: awk
^fatal: bad config file line {line} in {file} git
^llc: {file}:{line}:{col}: llc
^lua: {file}:{line}: lua
^{file} (line {line}): fish
^{file}: line {line}: sh, bash, ssh
^{file}:{line:col}-{line:col} cargo parsing config file
^{file}:{line}: zsh, ruby, make, ghc
^{file}:{line}:{col}: gcc, clang, rustc, go
^  File "{file}", line {line} thefuck, python
^    {file}:{line}:{col}: cargo compilation
at {file} line {line} perl
at {file}:{line}:{col} js, node

Feel free to add a comment if you have other ideas of easy to identify patterns.

SylvainDe commented 9 years ago

Wahoo! You guys are crazy! Thanks for the quick and comprehensive answers!

scorphus commented 9 years ago

Nice! My addition:

pattern tools note
at {file}:{line}:{col} js, node the pattern appears many times, should take the first reference
mcarton commented 9 years ago

@scorphus can you give me a full example of output for the tests?

scorphus commented 9 years ago

Absolutely!

// fuck.js
process.argv.slice(2).forEach(function(arg) {
    conole.log(arg);
});
» node fuck.js asdf qwer
/Users/pablo/Workspace/barebones/fuck.js:2
    conole.log(arg);  // this should read console.log(arg);
    ^
ReferenceError: conole is not defined
    at /Users/pablo/Workspace/barebones/fuck.js:2:5
    at Array.forEach (native)
    at Object.<anonymous> (/Users/pablo/Workspace/barebones/fuck.js:1:85)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3