Skip to content

Commit

Permalink
chore: lint all and remove unnecessary imports
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopsimek committed Feb 11, 2020
1 parent c1bb7f6 commit d61fe6a
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 55 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports = {
setupFiles: ['./src/jest.setup.ts'],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
setupFilesAfterEnv: ['./src/test/jest.setupFileAfterEnv.ts'],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
Expand Down
5 changes: 0 additions & 5 deletions src/detectors/ScanningStrategyDetector.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nock from 'nock';
import git from 'simple-git/promise';
import { createTestContainer } from '../inversify.config';
import { GitHubNock } from '../test/helpers/gitHubNock';
Expand All @@ -8,10 +7,6 @@ jest.mock('simple-git/promise');
describe('ScanningStrategyDetector', () => {
const mockedGit = <jest.Mock>git;

beforeEach(() => {
nock.cleanAll();
});

describe('#detect', () => {
it('local path without remote', async () => {
mockedGit.mockImplementation(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/inspectors/CollaborationInspector.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CollaborationInspector } from './CollaborationInspector';
import nock from 'nock';
import { TestContainerContext } from '../inversify.config';
import { createTestContainer } from '../inversify.config';
import { GitHubNock } from '../test/helpers/gitHubNock';
Expand Down Expand Up @@ -29,7 +28,6 @@ describe('Collaboration Inspector', () => {

beforeEach(async () => {
inspector = <CollaborationInspector>containerCtx.practiceContext.collaborationInspector;
nock.cleanAll();
});

it('returns paginated pull requests', async () => {
Expand Down
5 changes: 0 additions & 5 deletions src/inspectors/IssueTrackingInspector.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IssueTrackingInspector } from './IssueTrackingInspector';
import nock from 'nock';
import { TestContainerContext, createTestContainer } from '../inversify.config';
import { GitHubNock } from '../test/helpers/gitHubNock';
import {
Expand All @@ -20,10 +19,6 @@ describe('Issue Tracking Inspector', () => {
inspector = <IssueTrackingInspector>containerCtx.practiceContext.issueTrackingInspector;
});

beforeEach(() => {
nock.cleanAll();
});

it('returns paginated issues', async () => {
new GitHubNock('1', 'octocat', 1, 'Hello-World').getIssues().reply(200, getIssuesResponse);
const response = await inspector.listIssues('octocat', 'Hello-World');
Expand Down
3 changes: 0 additions & 3 deletions src/lib/assertNever.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { assertNever } from './assertNever';
import { ProgrammingLanguage, PracticeImpact } from '../model';
import { PracticeDetail } from '../practices/IPractice';
import { ReportDetailType, ReporterData } from '../reporters/ReporterData';

describe('AssertNever', () => {
it('Throws error if it is called', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nock from 'nock';
import { CollaborationInspector } from '../../inspectors/CollaborationInspector';
import { createTestContainer, TestContainerContext } from '../../inversify.config';
import { PracticeEvaluationResult } from '../../model';
Expand All @@ -14,10 +13,6 @@ describe('CorrectCommitMessagesPractice', () => {
const MockedCollaborationInspector = <jest.Mock<CollaborationInspector>>(<unknown>CollaborationInspector);
let mockCollaborationInspector: CollaborationInspector;

beforeEach(async () => {
nock.cleanAll();
});

beforeAll(() => {
containerCtx = createTestContainer();
containerCtx.container.bind('CorrectCommitMessagesPractice').to(CorrectCommitMessagesPractice);
Expand Down
5 changes: 0 additions & 5 deletions src/practices/LanguageIndependent/DoesPullRequests.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createTestContainer, TestContainerContext } from '../../inversify.config';
import { PracticeEvaluationResult } from '../../model';
import { DoesPullRequestsPractice } from './DoesPullRequests';
import nock from 'nock';
import { GitHubNock } from '../../test/helpers/gitHubNock';
import { getRepoCommitsResponse } from '../../services/git/__MOCKS__/gitHubServiceMockFolder/getRepoCommitsResponse.mock';
import { PullRequestState } from '../../inspectors/ICollaborationInspector';
Expand All @@ -10,10 +9,6 @@ describe('DoesPullRequests', () => {
let practice: DoesPullRequestsPractice;
let containerCtx: TestContainerContext;

beforeEach(async () => {
nock.cleanAll();
});

beforeAll(() => {
containerCtx = createTestContainer();
containerCtx.container.bind('DoesPullRequests').to(DoesPullRequestsPractice);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nock from 'nock';
import { CollaborationInspector } from '../../inspectors';
import { createTestContainer, TestContainerContext } from '../../inversify.config';
import { PracticeEvaluationResult } from '../../model';
Expand All @@ -8,18 +7,13 @@ import { ThinPullRequestsPractice } from './ThinPullRequestsPractice';
import { getPullRequestsResponse } from '../../services/git/__MOCKS__/bitbucketServiceMockFolder/getPullRequestsResponse';
import moment from 'moment';
import { getPullRequestResponse } from '../../services/git/__MOCKS__/bitbucketServiceMockFolder';
import _ from 'lodash';

describe('ThinPullRequestsPractice', () => {
let practice: ThinPullRequestsPractice;
let containerCtx: TestContainerContext;
const MockedCollaborationInspector = <jest.Mock<CollaborationInspector>>(<unknown>CollaborationInspector);
let mockCollaborationInspector: CollaborationInspector;

beforeEach(async () => {
nock.cleanAll();
});

beforeAll(() => {
containerCtx = createTestContainer();
containerCtx.container.bind('ThinPullRequestsPractice').to(ThinPullRequestsPractice);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import moment from 'moment';
import nock from 'nock';
import { IssueTrackingInspector } from '../../inspectors';
import { createTestContainer, TestContainerContext } from '../../inversify.config';
import { PracticeEvaluationResult } from '../../model';
Expand All @@ -16,10 +15,6 @@ describe('TimeToSolveIssuesPractice', () => {
const MockedIssueTrackingInspector = <jest.Mock<IssueTrackingInspector>>(<unknown>IssueTrackingInspector);
let mockIssueTrackingInspector: IssueTrackingInspector;

beforeEach(async () => {
nock.cleanAll();
});

beforeAll(() => {
containerCtx = createTestContainer();
containerCtx.container.bind('TimeToSolveIssuesPractice').to(TimeToSolveIssuesPractice);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import moment from 'moment';
import nock from 'nock';
import { CollaborationInspector } from '../../inspectors';
import { createTestContainer, TestContainerContext } from '../../inversify.config';
import { PracticeEvaluationResult } from '../../model';
Expand All @@ -16,10 +15,6 @@ describe('TimeToSolvePullRequestsPractice', () => {
const MockedCollaborationInspector = <jest.Mock<CollaborationInspector>>(<unknown>CollaborationInspector);
let mockCollaborationInspector: CollaborationInspector;

beforeEach(async () => {
nock.cleanAll();
});

beforeAll(() => {
containerCtx = createTestContainer();
containerCtx.container.bind('TimeToSolvePractice').to(TimeToSolvePullRequestsPractice);
Expand Down
1 change: 0 additions & 1 deletion src/practices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { TimeToSolvePullRequestsPractice } from './LanguageIndependent/TimeToSol
import { TimeToSolveIssuesPractice } from './LanguageIndependent/TimeToSolveIssuesPractice';
import { ThinPullRequestsPractice } from './LanguageIndependent/ThinPullRequestsPractice';
import { SecurityVulnerabilitiesPractice } from './JavaScript/SecurityVulnerabilitiesPractice';
import { FirstTestPractice, SecondTestPractice, InvalidTestPractice } from '../scanner';
import { JavaPackageManagementUsedPractice } from './Java/JavaPackageManagementUsedPractice';
import { JavaLoggerUsedPractice } from './Java/JavaLoggerUsedPractice';
import { JavaTestingFrameworkUsedPractice } from './Java/JavaTestingFrameworkUsedPractice';
Expand Down
4 changes: 1 addition & 3 deletions src/services/bitbucket/BitbucketService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nock from 'nock';
import { PullRequestState, IssueState } from '../../inspectors';
import {
getIssueResponse,
Expand All @@ -24,7 +23,7 @@ describe('Bitbucket Service', () => {

beforeEach(async () => {
service = new BitbucketService(argumentsProviderFactory({ uri: '.' }));
nock.cleanAll();

bitbucketNock = new BitbucketNock('pypy', 'pypy');
});

Expand Down Expand Up @@ -131,7 +130,6 @@ describe('Bitbucket Service', () => {

it('returns open issues in own interface', async () => {
const mockIssue = bitbucketIssueResponseFactory({ state: BitbucketIssueState.new });
bitbucketNock.getOwnerId();
bitbucketNock.listIssuesResponse([mockIssue], { filter: { state: BitbucketIssueState.new } });

const response = await service.listIssues('pypy', 'pypy', { filter: { state: IssueState.open } });
Expand Down
4 changes: 0 additions & 4 deletions src/services/git/Git.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Git } from './Git';
import { GitHubNock } from '../../test/helpers/gitHubNock';
import nock from 'nock';
import { GitHubService } from './GitHubService';
import { argumentsProviderFactory } from '../../test/factories/ArgumentsProviderFactory';

Expand All @@ -15,7 +14,6 @@ describe('Git', () => {

beforeEach(() => {
service.purgeCache();
nock.cleanAll();
});

describe('#exists', () => {
Expand Down Expand Up @@ -240,8 +238,6 @@ describe('Git', () => {
it('stops on false', async () => {
gitHubNock.getDirectory('mockFolder', ['mockFile.ts'], ['mockSubFolder']);
gitHubNock.getFile('mockFolder/mockFile.ts');
gitHubNock.getDirectory('mockFolder/mockSubFolder', ['mockSubFolderFile.txt'], []);
gitHubNock.getFile('mockFolder/mockSubFolder/mockSubFolderFile.txt');

const files: string[] = [];

Expand Down
2 changes: 0 additions & 2 deletions src/services/git/GitHubService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
import nock from 'nock';
import { GitHubService } from './GitHubService';
import { GitHubNock } from '../../test/helpers/gitHubNock';
import {
Expand Down Expand Up @@ -34,7 +33,6 @@ describe('GitHub Service', () => {

beforeEach(async () => {
service = new GitHubService(argumentsProviderFactory({ uri: '.' }));
nock.cleanAll();
});

describe('#getPullRequests', () => {
Expand Down
1 change: 0 additions & 1 deletion src/services/git/VCSServicesUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PullRequestState } from '../../inspectors/ICollaborationInspector';
import { VCSServiceType } from './IVCSService';
import { GitHubIssueState } from './IGitHubService';
import { IssueState } from '../../inspectors';
import { BitbucketIssueState, BitbucketPullRequestState } from '../bitbucket/IBitbucketService';
Expand Down
2 changes: 0 additions & 2 deletions src/test/helpers/bitbucketNock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { bitbucketListPRsResponseFactory } from '../factories/responses/bitbucke
import { bitbucketListPullCommitsResponseFactory } from '../factories/responses/bitbucket/listPullCommitsResponseFactory';
import { bitbucketListCommitResponseFactory } from '../factories/responses/bitbucket/listRepoCommitsResponseFactory';
import { BitbucketPullRequestState, BitbucketIssueState } from '../../services/bitbucket/IBitbucketService';
import _ from 'lodash';
import qs from 'qs';
import { VCSServicesUtils } from '../../services/git/VCSServicesUtils';

export class BitbucketNock {
Expand Down
5 changes: 5 additions & 0 deletions src/test/jest.setupFileAfterEnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import nock from 'nock';

beforeEach(() => {
nock.cleanAll();
});

0 comments on commit d61fe6a

Please sign in to comment.