Skip to content

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

Open
AkshJain99 wants to merge 1 commit intocoala:masterfrom
AkshJain99:sir
Open

plugins:Add plugin for saying no to 'sir'#651
AkshJain99 wants to merge 1 commit intocoala:masterfrom
AkshJain99:sir

Conversation

@AkshJain99
Copy link
Copy Markdown
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.

Comment thread plugins/no_sir.py Outdated
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
Copy link
Copy Markdown

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]
-				)
+                )
 			)```

Copy link
Copy Markdown

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
Copy Markdown
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

Comment thread plugins/no_sir.py Outdated
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
) No newline at end of file
Copy link
Copy Markdown

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]
 				)
-			)+            )

Comment thread tests/no_sir_test.py Outdated

def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message() No newline at end of file
Copy link
Copy Markdown

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()

Comment thread plugins/no_sir.py Outdated
@@ -0,0 +1,18 @@
import re

from errbot import BotPlugin, re_botcmd
Copy link
Copy Markdown

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):

Comment thread tests/no_sir_test.py Outdated
@@ -0,0 +1,11 @@
import os
Copy link
Copy Markdown

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
 

Comment thread plugins/no_sir.py Outdated


class no_sir(BotPlugin):
"""
Copy link
Copy Markdown

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]
+                                      )
+                              )

Comment thread plugins/no_sir.py Outdated


class no_sir(BotPlugin):
"""
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
"""
Do not use sir
"""
def callback_message(self, msg):
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
def callback_message(self, msg):
emots = [':D']
if match_sir:
self.send(
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
) No newline at end of file
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
) No newline at end of file
Copy link
Copy Markdown

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.

Comment thread tests/no_sir_test.py Outdated

def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message() No newline at end of file
Copy link
Copy Markdown

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()

Comment thread tests/no_sir_test.py Outdated

def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message() No newline at end of file
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
Copy link
Copy Markdown

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]
-				)
+                )
 			)

Comment thread plugins/no_sir.py Outdated
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
)
Copy link
Copy Markdown

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]
 				)
-			)
+            )

Comment thread plugins/no_sir.py Outdated
@@ -0,0 +1,18 @@
import re

from errbot import BotPlugin, re_botcmd
Copy link
Copy Markdown

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):

Comment thread tests/no_sir_test.py Outdated
@@ -0,0 +1,11 @@
import os
Copy link
Copy Markdown

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
 

Comment thread plugins/no_sir.py Outdated


class no_sir(BotPlugin):
"""
Copy link
Copy Markdown

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]
+                                      )
+                              )

Comment thread plugins/no_sir.py Outdated


class no_sir(BotPlugin):
"""
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
"""
Do not use sir
"""
def callback_message(self, msg):
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
def callback_message(self, msg):
emots = [':D']
if match_sir:
self.send(
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
)
Copy link
Copy Markdown

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
Copy Markdown

@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 :)

Comment thread plugins/no_sir.py Outdated
"""
def callback_message(self, msg):
emots = [':D']
if match_sir:
Copy link
Copy Markdown

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.

Comment thread plugins/no_sir.py Outdated
msg.frm,
'@{}, Do not use sir in your conversation. {}'.format(
msg.frm.nick, emots[0]
)
Copy link
Copy Markdown

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.

Comment thread tests/no_sir_test.py Outdated
extra_plugin_dir = '.'

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

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.

Comment thread tests/no_sir_test.py

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

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
Copy Markdown
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

Copy link
Copy Markdown

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 :)

@AkshJain99 AkshJain99 force-pushed the sir branch 4 times, most recently from bbedddb to 735270b Compare March 10, 2019 10:11
we have added a plugin and related test
to prevent any contributor from saying sir.

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

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?

Copy link
Copy Markdown

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
Copy Markdown

@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
Copy Markdown

@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
Copy Markdown
Member Author

AkshJain99 commented Apr 23, 2019 via email

@AkshJain99
Copy link
Copy Markdown
Member Author

AkshJain99 commented Apr 23, 2019 via email

Comment thread tests/no_sir_test.py

def test_no_sir(self, testbot):
testbot.push_message('sir')
assert 'Do not use sir in your conversation' in testbot.pop_message()
Copy link
Copy Markdown
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

Comment thread plugins/no_sir.py
from errbot import BotPlugin


class no_sir(BotPlugin):
Copy link
Copy Markdown
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
Copy Markdown
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