Skip to content

Commit

Permalink
fix: add new practicesWitchContext for every component in for loop. (#46
Browse files Browse the repository at this point in the history
)

* fix: add new practicesWitchContext for every component in for loop.

* Update src/scanner/Scanner.ts

* Update src/scanner/Scanner.ts
  • Loading branch information
adelkahomolova authored and prokopsimek committed Sep 12, 2019
1 parent 0704a63 commit d5d50db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/scanner/Scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ScannerUtils } from './ScannerUtils';
import { ArgumentsProvider } from '../inversify.config';
import { IPracticeWithMetadata } from '../practices/DxPracticeDecorator';
import filterAsync from 'node-filter-async';
import util from 'util';

@injectable()
export class Scanner {
Expand Down Expand Up @@ -135,7 +136,9 @@ export class Scanner {

private async detectPractices(componentsWithContext: ProjectComponentAndLangContext[]): Promise<PracticeWithContext[]> {
const practicesWithContext: PracticeWithContext[] = [];

for (const componentWithCtx of componentsWithContext) {
const practicesWithContextFromComponent: PracticeWithContext[] = [];
const componentContext = componentWithCtx.languageContext.getProjectComponentContext(componentWithCtx.component);
const practiceContext = componentContext.getPracticeContext();

Expand All @@ -145,7 +148,8 @@ export class Scanner {

const orderedApplicablePractices = ScannerUtils.sortPractices(applicablePractices);
for (const practice of orderedApplicablePractices) {
const isFulfilled = ScannerUtils.isFulfilled(practice, practicesWithContext);
const isFulfilled = ScannerUtils.isFulfilled(practice, practicesWithContextFromComponent);

if (!isFulfilled) continue;

const evaluation = await practice.evaluate(practiceContext);
Expand Down

0 comments on commit d5d50db

Please sign in to comment.