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

Suggest ag -Q when relevant #561

Merged
merged 6 commits into from
Oct 7, 2016
Merged

Suggest ag -Q when relevant #561

merged 6 commits into from
Oct 7, 2016

Conversation

josephfrazier
Copy link
Collaborator

This detects when ag suggests the -Q option, and adds it.

This detects when `ag` suggests the `-Q` option, and adds it.
@coveralls
Copy link

coveralls commented Oct 3, 2016

Coverage Status

Coverage increased (+0.03%) to 93.121% when pulling db4b379 on josephfrazier:ag-literal into db7dffd on nvbn:master.

@coveralls
Copy link

coveralls commented Oct 3, 2016

Coverage Status

Coverage increased (+0.03%) to 93.121% when pulling b090596 on josephfrazier:ag-literal into db7dffd on nvbn:master.

@coveralls
Copy link

coveralls commented Oct 3, 2016

Coverage Status

Coverage increased (+0.03%) to 93.147% when pulling d2e0a19 on josephfrazier:ag-literal into ce6b82c on nvbn:master.

Copy link
Collaborator

@scorphus scorphus left a comment

Choose a reason for hiding this comment

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

Nice additions. I've gathered some comments.

Thanks!


matching_command = Command(script='ag \\(', stderr=stderr)

@pytest.mark.parametrize('command', [
Copy link
Collaborator

@scorphus scorphus Oct 5, 2016

Choose a reason for hiding this comment

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

Please, add a new line here. [E302 expected 2 blank lines, found 1]

@@ -0,0 +1,11 @@
from thefuck.utils import for_app
from thefuck.utils import replace_argument
Copy link
Collaborator

@scorphus scorphus Oct 5, 2016

Choose a reason for hiding this comment

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

Please remove this unused import. [F401 imported but unused]

@pytest.mark.parametrize('command, new_command', [
(matching_command, 'ag -Q \\(')])
def test_get_new_command(command, new_command):
assert get_new_command(command) == new_command
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd recommend refactoring the test as the following:

import pytest
from thefuck.rules.ag_literal import get_new_command, match
from tests.utils import Command


@pytest.fixture
def stderr():
    return ('ERR: Bad regex! pcre_compile() failed at position 1: missing )\n'
            'If you meant to search for a literal string, run ag with -Q\n')


@pytest.mark.parametrize('script', ['ag \('])
def test_match(script, stderr):
    assert match(Command(script=script, stderr=stderr))


@pytest.mark.parametrize('script', ['ag foo'])
def test_not_match(script):
    assert not match(Command(script=script))


@pytest.mark.parametrize('script, new_cmd', [
    ('ag \(', 'ag -Q \(')])
def test_get_new_command(script, new_cmd, stderr):
    assert get_new_command((Command(script=script, stderr=stderr))) == new_cmd


@for_app('ag')
def match(command):
return 'run ag with -Q' in command.stderr
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't endswith() a slightly better option than in?

@coveralls
Copy link

coveralls commented Oct 5, 2016

Coverage Status

Coverage increased (+0.03%) to 93.145% when pulling a964af7 on josephfrazier:ag-literal into ce6b82c on nvbn:master.

@josephfrazier
Copy link
Collaborator Author

Thanks for the review, @scorphus! I've made some changes addressing your comments.

Copy link
Collaborator

@scorphus scorphus left a comment

Choose a reason for hiding this comment

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

You nailed it, @josephfrazier! 👍

Thanks!

@nvbn
Copy link
Owner

nvbn commented Oct 7, 2016

Thanks!

@nvbn nvbn merged commit 8f4f2f0 into nvbn:master Oct 7, 2016
@josephfrazier josephfrazier deleted the ag-literal branch October 7, 2016 15:03
riley-martine pushed a commit to riley-martine/thefuck that referenced this pull request Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this pull request Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this pull request Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this pull request Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this pull request Dec 7, 2023
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.

4 participants