Total Complexity | 2 |
Total Lines | 24 |
Duplicated Lines | 0 % |
1 | import os |
||
12 | @skipIf(which('eslint') is None, 'ESLint is not installed') |
||
|
|||
13 | class ESLintBearTest(LocalBearTestHelper): |
||
14 | |||
15 | def setUp(self): |
||
16 | self.section = Section("test section") |
||
17 | self.uut = ESLintBear(self.section, Queue()) |
||
18 | self.test_good = os.path.join(os.path.dirname(__file__), |
||
19 | "test_files", |
||
20 | "eslint_good.js") |
||
21 | self.test_bad = os.path.join(os.path.dirname(__file__), |
||
22 | "test_files", |
||
23 | "eslint_bad.js") |
||
24 | self.test_config = os.path.join(os.path.dirname(__file__), |
||
25 | "test_files", |
||
26 | "eslint_config.js") |
||
27 | |||
28 | def test_run(self): |
||
29 | # Test a file with errors and warnings |
||
30 | self.assertLinesInvalid(self.uut, [], self.test_bad) |
||
31 | # Test a file without errors and warnings |
||
32 | self.assertLinesValid(self.uut, [], self.test_good) |
||
33 | # Append the config to the file with errors and test again |
||
34 | self.section.append(Setting("eslint_config", self.test_config)) |
||
35 | self.assertLinesValid(self.uut, [], self.test_bad) |
||
36 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.