From 18a5b33aac03dfdedc977356c4335832e7ca501f Mon Sep 17 00:00:00 2001 From: Manank Patni Date: Wed, 18 Jul 2018 22:53:24 +0530 Subject: [PATCH] .coafile: Add the PyUnusedCodeBear to the file Added the PyUnusedCodeBear to the .coafile and ran coala command. This bear will remove the unused code from the project files. The bear is added to the [all.python] section. Fixes https://github.com/coala/corobo/issues/531 --- .coafile | 1 + answers/final.py | 3 --- answers/service.py | 2 -- plugins/coatils.py | 2 -- plugins/explain.py | 1 - plugins/labhub.py | 1 - tests/answer_test.py | 1 - tests/coatils_test.py | 3 +-- tests/git_stats_test.py | 2 +- tests/labhub_test.py | 2 -- tests/wolfram_alpha_test.py | 1 - 11 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.coafile b/.coafile index 274ed76c..14d4c3ff 100644 --- a/.coafile +++ b/.coafile @@ -16,6 +16,7 @@ default_actions = *: ApplyPatchAction bears += KeywordBear keywords = pdb +bears += PyUnusedCodeBear [all.autopep8] bears = PEP8Bear, PycodestyleBear diff --git a/answers/final.py b/answers/final.py index be262b91..f71aeb69 100644 --- a/answers/final.py +++ b/answers/final.py @@ -1,5 +1,4 @@ from collections import OrderedDict, Counter -import logging from gensim.parsing.preprocessing import STOPWORDS from gensim.utils import simple_preprocess @@ -60,9 +59,7 @@ def get_answer(question, graph, final=False): grapheize(q_graph, q_doc, attrs={'q_type': q_type}) scores = Counter() - found_common = False for start, end in q_graph.edges(): - found_common = True if start in graph and end in graph: for path in networkx.algorithms.all_shortest_paths( graph, start, end): diff --git a/answers/service.py b/answers/service.py index 9cd6ac38..11f597fd 100644 --- a/answers/service.py +++ b/answers/service.py @@ -1,5 +1,3 @@ -import json -import os from flask import Flask, jsonify, request from gensim.summarization import summarize diff --git a/plugins/coatils.py b/plugins/coatils.py index 390e2a72..1d52e906 100644 --- a/plugins/coatils.py +++ b/plugins/coatils.py @@ -1,6 +1,5 @@ from collections import OrderedDict import json -import os import textwrap import requests @@ -110,7 +109,6 @@ def ls(self, msg, match): Example: `ls bears python python3` """ langs = list(map(lambda x: x.lower(), match.group(1).split())) - all_langs = Coatils.all_langs() bears = client.list.bears.get().json() bears = [{**{'name': bear}, **content} diff --git a/plugins/explain.py b/plugins/explain.py index 1c37b838..07990077 100644 --- a/plugins/explain.py +++ b/plugins/explain.py @@ -1,6 +1,5 @@ import re import glob -import os.path from errbot import BotPlugin, re_botcmd from errbot.templating import tenv diff --git a/plugins/labhub.py b/plugins/labhub.py index cee87e6c..4abc6379 100644 --- a/plugins/labhub.py +++ b/plugins/labhub.py @@ -1,5 +1,4 @@ import datetime -import json import os import re import time diff --git a/tests/answer_test.py b/tests/answer_test.py index aa3a3d58..8ad64043 100644 --- a/tests/answer_test.py +++ b/tests/answer_test.py @@ -1,5 +1,4 @@ import os -import unittest import logging from errbot.backends.test import FullStackTest diff --git a/tests/coatils_test.py b/tests/coatils_test.py index 02e822bc..cf3ad1da 100644 --- a/tests/coatils_test.py +++ b/tests/coatils_test.py @@ -1,5 +1,4 @@ import logging -import unittest import queue from errbot.backends.test import FullStackTest @@ -88,7 +87,7 @@ def test_run_coala(self): # ensuring that only one result is yielded with self.assertRaises(queue.Empty): - next_msg = self.pop_message() + self.pop_message() # error self.push_message('!run a b\n```\nc\n```') self.assertEqual(self.pop_message(), diff --git a/tests/git_stats_test.py b/tests/git_stats_test.py index 6935cefb..4f16d0e7 100644 --- a/tests/git_stats_test.py +++ b/tests/git_stats_test.py @@ -2,7 +2,7 @@ from tempfile import mkdtemp from errbot import BotPlugin import unittest -from unittest.mock import Mock, MagicMock, create_autospec, PropertyMock, patch +from unittest.mock import create_autospec from IGitt.GitHub.GitHubMergeRequest import GitHubMergeRequest from IGitt.GitLab.GitLabMergeRequest import GitLabMergeRequest diff --git a/tests/labhub_test.py b/tests/labhub_test.py index 5154b2ea..5a995a0e 100644 --- a/tests/labhub_test.py +++ b/tests/labhub_test.py @@ -1,8 +1,6 @@ import logging -import os import queue import textwrap -import time import unittest from unittest.mock import Mock, MagicMock, create_autospec, PropertyMock, patch diff --git a/tests/wolfram_alpha_test.py b/tests/wolfram_alpha_test.py index 12c46ff2..e415cd2b 100755 --- a/tests/wolfram_alpha_test.py +++ b/tests/wolfram_alpha_test.py @@ -1,4 +1,3 @@ -import unittest import logging import vcr