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

plugins:Add plugin for saying no to 'sir' #651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AkshJain99
Copy link
Member

@AkshJain99 AkshJain99 commented Mar 9, 2019

Reviewers Checklist

  • Appropriate logging is done.
  • Appropriate error responses.
  • Handle every possible exception.
  • Make sure there is a docstring in the command functions. Hint: Lookout for
    botcmd and re_botcmd decorators.
  • See that 100% coverage is there.
  • See to it that mocking is not done where it is not necessary.

msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Tabs used instead of spaces.

Origin: SpaceConsistencyBear, Section: all.whitespace.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpa6hrtctc/plugins/no_sir.py
+++ b/tmp/tmpa6hrtctc/plugins/no_sir.py
@@ -14,5 +14,5 @@
         msg.frm,
         '@{}, Do not use sir in your conversation. {}'.format(
           msg.frm.nick, emots[0]
-				)
+                )
 			)```

Choose a reason for hiding this comment

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

Kindly use VSCode or any other editor to avoid such warnings.

Copy link
Member Author

Choose a reason for hiding this comment

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

I use VS code only

'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
)

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • No newline at EOF.
  • Tabs used instead of spaces.

Origin: SpaceConsistencyBear, Section: all.whitespace.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpa6hrtctc/plugins/no_sir.py
+++ b/tmp/tmpa6hrtctc/plugins/no_sir.py
@@ -15,4 +15,4 @@
         '@{}, Do not use sir in your conversation. {}'.format(
           msg.frm.nick, emots[0]
 				)
-			)+            )


def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message()

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • No newline at EOF.

Origin: SpaceConsistencyBear, Section: all.whitespace.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpa6hrtctc/tests/no_sir_test.py
+++ b/tmp/tmpa6hrtctc/tests/no_sir_test.py
@@ -8,4 +8,4 @@
 
     def test_no_sir(self, testbot):
         testbot.push_message('sir')
-        assert 'Do not use sir in your conversation' in testbot.pop_message()+        assert 'Do not use sir in your conversation' in testbot.pop_message()

@@ -0,0 +1,18 @@
import re

from errbot import BotPlugin, re_botcmd

Choose a reason for hiding this comment

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

This file contains unused source code.

Origin: PyUnusedCodeBear, Section: all.python.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpa6hrtctc/plugins/no_sir.py
+++ b/tmp/tmpa6hrtctc/plugins/no_sir.py
@@ -1,6 +1,7 @@
 import re
 
-from errbot import BotPlugin, re_botcmd
+from errbot import BotPlugin
+from errbot import re_botcmd
 
 
 class no_sir(BotPlugin):

@@ -0,0 +1,11 @@
import os

Choose a reason for hiding this comment

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

This file contains unused source code.

Origin: PyUnusedCodeBear, Section: all.python.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpa6hrtctc/tests/no_sir_test.py
+++ b/tmp/tmpa6hrtctc/tests/no_sir_test.py
@@ -1,4 +1,3 @@
-import os
 import no_sir
 from errbot.backends.test import testbot
 



class no_sir(BotPlugin):
"""

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

Origin: PEP8Bear, Section: all.autopep8.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpa6hrtctc/plugins/no_sir.py
+++ b/tmp/tmpa6hrtctc/plugins/no_sir.py
@@ -4,15 +4,16 @@
 
 
 class no_sir(BotPlugin):
-  """
-  Do not use sir
-  """
-  def callback_message(self, msg):
-    emots = [':D']
-    if match_sir:
-      self.send(
-        msg.frm,
-        '@{}, Do not use sir in your conversation. {}'.format(
-          msg.frm.nick, emots[0]
-				)
-			)+    """
+    Do not use sir
+    """
+
+    def callback_message(self, msg):
+        emots = [':D']
+        if match_sir:
+            self.send(
+              msg.frm,
+              '@{}, Do not use sir in your conversation. {}'.format(
+                msg.frm.nick, emots[0]
+                                      )
+                              )



class no_sir(BotPlugin):
"""

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

Origin: PycodestyleBear (E111), Section: all.autopep8.

"""
Do not use sir
"""
def callback_message(self, msg):

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

Origin: PycodestyleBear (E111), Section: all.autopep8.

def callback_message(self, msg):
emots = [':D']
if match_sir:
self.send(

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

Origin: PycodestyleBear (E111), Section: all.autopep8.

msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)

Choose a reason for hiding this comment

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

E101 indentation contains mixed spaces and tabs

Origin: PycodestyleBear (E101), Section: all.autopep8.

msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)

Choose a reason for hiding this comment

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

W191 indentation contains tabs

Origin: PycodestyleBear (W191), Section: all.autopep8.

'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
)

Choose a reason for hiding this comment

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

W191 indentation contains tabs

Origin: PycodestyleBear (W191), Section: all.autopep8.

'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
)

Choose a reason for hiding this comment

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

W292 no newline at end of file

Origin: PycodestyleBear (W292), Section: all.autopep8.


def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message()

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

Origin: PEP8Bear, Section: all.autopep8.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpa6hrtctc/tests/no_sir_test.py
+++ b/tmp/tmpa6hrtctc/tests/no_sir_test.py
@@ -8,4 +8,4 @@
 
     def test_no_sir(self, testbot):
         testbot.push_message('sir')
-        assert 'Do not use sir in your conversation' in testbot.pop_message()+        assert 'Do not use sir in your conversation' in testbot.pop_message()


def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message()

Choose a reason for hiding this comment

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

W292 no newline at end of file

Origin: PycodestyleBear (W292), Section: all.autopep8.

msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Tabs used instead of spaces.

Origin: SpaceConsistencyBear, Section: all.whitespace.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpbr1ao5rr/plugins/no_sir.py
+++ b/tmp/tmpbr1ao5rr/plugins/no_sir.py
@@ -14,5 +14,5 @@
         msg.frm,
         '@{}, Do not use sir in your conversation. {}'.format(
           msg.frm.nick, emots[0]
-				)
+                )
 			)

'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
)

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Tabs used instead of spaces.

Origin: SpaceConsistencyBear, Section: all.whitespace.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpbr1ao5rr/plugins/no_sir.py
+++ b/tmp/tmpbr1ao5rr/plugins/no_sir.py
@@ -15,4 +15,4 @@
         '@{}, Do not use sir in your conversation. {}'.format(
           msg.frm.nick, emots[0]
 				)
-			)
+            )

@@ -0,0 +1,18 @@
import re

from errbot import BotPlugin, re_botcmd

Choose a reason for hiding this comment

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

This file contains unused source code.

Origin: PyUnusedCodeBear, Section: all.python.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpbr1ao5rr/plugins/no_sir.py
+++ b/tmp/tmpbr1ao5rr/plugins/no_sir.py
@@ -1,6 +1,7 @@
 import re
 
-from errbot import BotPlugin, re_botcmd
+from errbot import BotPlugin
+from errbot import re_botcmd
 
 
 class no_sir(BotPlugin):

@@ -0,0 +1,11 @@
import os

Choose a reason for hiding this comment

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

This file contains unused source code.

Origin: PyUnusedCodeBear, Section: all.python.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpbr1ao5rr/tests/no_sir_test.py
+++ b/tmp/tmpbr1ao5rr/tests/no_sir_test.py
@@ -1,4 +1,3 @@
-import os
 import no_sir
 from errbot.backends.test import testbot
 



class no_sir(BotPlugin):
"""

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

Origin: PEP8Bear, Section: all.autopep8.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpbr1ao5rr/plugins/no_sir.py
+++ b/tmp/tmpbr1ao5rr/plugins/no_sir.py
@@ -4,15 +4,16 @@
 
 
 class no_sir(BotPlugin):
-  """
-  Do not use sir
-  """
-  def callback_message(self, msg):
-    emots = [':D']
-    if match_sir:
-      self.send(
-        msg.frm,
-        '@{}, Do not use sir in your conversation. {}'.format(
-          msg.frm.nick, emots[0]
-				)
-			)
+    """
+    Do not use sir
+    """
+
+    def callback_message(self, msg):
+        emots = [':D']
+        if match_sir:
+            self.send(
+              msg.frm,
+              '@{}, Do not use sir in your conversation. {}'.format(
+                msg.frm.nick, emots[0]
+                                      )
+                              )



class no_sir(BotPlugin):
"""

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

Origin: PycodestyleBear (E111), Section: all.autopep8.

"""
Do not use sir
"""
def callback_message(self, msg):

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

Origin: PycodestyleBear (E111), Section: all.autopep8.

def callback_message(self, msg):
emots = [':D']
if match_sir:
self.send(

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

Origin: PycodestyleBear (E111), Section: all.autopep8.

msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)

Choose a reason for hiding this comment

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

E101 indentation contains mixed spaces and tabs

Origin: PycodestyleBear (E101), Section: all.autopep8.

msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)

Choose a reason for hiding this comment

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

W191 indentation contains tabs

Origin: PycodestyleBear (W191), Section: all.autopep8.

'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
)

Choose a reason for hiding this comment

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

W191 indentation contains tabs

Origin: PycodestyleBear (W191), Section: all.autopep8.

Copy link

@sladyn98 sladyn98 left a comment

Choose a reason for hiding this comment

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

Kindly run coala before you submit the changes :)

"""
def callback_message(self, msg):
emots = [':D']
if match_sir:

Choose a reason for hiding this comment

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

@AkshJain99 What are you trying to do here? You instead should use a regex expression because the word sir could be present anywhere in the message.

msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)

Choose a reason for hiding this comment

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

Kindly use VSCode or any other editor to avoid such warnings.

extra_plugin_dir = '.'

def test_no_sir(self, testbot):
testbot.push_message('sir')

Choose a reason for hiding this comment

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

Please read the above comment,this is just covering one of the scenarios.


def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message()

Choose a reason for hiding this comment

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

The assert statement does not match the bot output message, the test would always throw an assertion error because of the missing emot at the end

Copy link
Member

Choose a reason for hiding this comment

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

@sladyn98 it's in

Choose a reason for hiding this comment

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

@meetmangukiya Yeah your right,so it would pass, but it would be better to keep the outputs same although it doesnt matter :)

we have added a plugin and related test
to prevent any contributor from saying sir.

Closes coala#337
if match_sir:
self.send(
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
Copy link

Choose a reason for hiding this comment

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

Please remove comma after mentioning the user!
Although the returned message is OK, I guess it could be more informative.
What do you think @sladyn98?

Choose a reason for hiding this comment

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

@KVGarg Definitely if you have any suggestions you could have written here :)

Copy link

@KVGarg KVGarg Apr 23, 2019

Choose a reason for hiding this comment

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

I guess we can frame a message somewhat like this

Hi @<username> :wave:! We don't use "Sir" in the community during the 
conversation. It's perfectly fine to call them via there usernames or handle. 
Also, If you want to do such think you can better go with buddy or something else :smiley: 

Something like this the message can be framed!

Copy link

@KVGarg KVGarg left a comment

Choose a reason for hiding this comment

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

Please re-base your branch!

@AkshJain99
Copy link
Member Author

AkshJain99 commented Apr 23, 2019 via email

@AkshJain99
Copy link
Member Author

AkshJain99 commented Apr 23, 2019 via email


def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message()
Copy link
Member

Choose a reason for hiding this comment

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

@sladyn98 it's in

from errbot import BotPlugin


class no_sir(BotPlugin):
Copy link
Member

Choose a reason for hiding this comment

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

class name not starting with caps 😱

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats by mistake @meetmangukiya i will correct all the issues now in this pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants