Skip to content

Commit eb4f8b5

Browse files
Deyan Ginevrosen-vladimirov
authored andcommitted
Addressing linter issues and comments.
1 parent 8049a2a commit eb4f8b5

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

lib/services/ios-log-filter.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter {
1111
// Example:
1212
// This: "May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:"
1313
// Becomes: CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:
14-
protected infoFilterRegex = new RegExp(`^.*(?:<Notice>:|<Error>:|<Warning>:|\\(NativeScript\\)|${this.appOutputRegex.source}:){1}`);
14+
protected infoFilterRegex = new RegExp(`^.*(?:<Notice>:|<Error>:|<Warning>:|\\(NativeScript\\)|${this.appOutputRegex.source}:){1}`);
1515

1616
private filterActive: boolean = true;
17-
private projectName: string;
1817

1918
private partialLine: string = null;
2019

2120
constructor(
2221
private $loggingLevels: Mobile.ILoggingLevels,
2322
private $fs: IFileSystem,
2423
private $projectData: IProjectData) {
25-
this.projectName = this.$projectData.projectName;
2624
}
2725

2826
public filterData(data: string, logLevel: string, pid?: string): string {
@@ -57,7 +55,10 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter {
5755

5856
if (matchResult && matchResult.length > 1) {
5957
// Check if the name of the app equals the name of the CLI project and turn on the filter if not.
60-
this.filterActive = matchResult[1] !== this.projectName;
58+
// We call initializeProjectData in order to obtain the current project name as the instance
59+
// of this filter may be used accross multiple projects.
60+
this.$projectData.initializeProjectData();
61+
this.filterActive = matchResult[1] !== this.$projectData.projectName;
6162
}
6263

6364
if (this.filterActive) {
@@ -76,11 +77,11 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter {
7677
return output.length === 0 ? null : output;
7778
}
7879

79-
private preFilter(data:string, currentLine: string): boolean {
80+
private preFilter(data: string, currentLine: string): boolean {
8081
return currentLine.length < 1 ||
81-
currentLine.indexOf("SecTaskCopyDebugDescription") !== -1 ||
82-
currentLine.indexOf("NativeScript loaded bundle") !== -1 ||
83-
(currentLine.indexOf("assertion failed:") !== -1 && data.indexOf("libxpc.dylib") !== -1);
82+
currentLine.indexOf("SecTaskCopyDebugDescription") !== -1 ||
83+
currentLine.indexOf("NativeScript loaded bundle") !== -1 ||
84+
(currentLine.indexOf("assertion failed:") !== -1 && data.indexOf("libxpc.dylib") !== -1);
8485
}
8586

8687
private getOriginalFileLocation(data: string): string {

test/services/ios-log-filter.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,20 @@ describe("iOSLogFilter", () => {
181181
it(`returns correct data on iOS ${data.version} when data comes in chunks`, () => {
182182
testInjector = createTestInjector(data.projectName);
183183
logFilter = testInjector.resolve(IOSLogFilter);
184-
184+
185185
let currentStart = 0;
186-
let maxRange = 50;
187-
let output = ""
188-
let input = data.originalDataArr.join("\n");
186+
const maxRange = 50;
187+
let output = "";
188+
const input = data.originalDataArr.join("\n");
189189
while (true) {
190-
let currentRange = Math.floor(Math.random() * maxRange);
191-
let currentFilterInput = input.substr(currentStart, currentRange);
192-
let tempOutput = logFilter.filterData(currentFilterInput, infoLogLevel, null);
190+
const currentRange = Math.floor(Math.random() * maxRange);
191+
const currentFilterInput = input.substr(currentStart, currentRange);
192+
const tempOutput = logFilter.filterData(currentFilterInput, infoLogLevel, null);
193193
if (tempOutput !== null) {
194194
output += tempOutput;
195195
}
196196
currentStart += currentRange;
197-
if (currentStart == input.length) {
197+
if (currentStart === input.length) {
198198
break;
199199
}
200200
currentStart = Math.min(currentStart, input.length);
@@ -243,7 +243,7 @@ describe("iOSLogFilter", () => {
243243
logFilter = testInjector.resolve(IOSLogFilter);
244244
data.originalDataArr.forEach((line, index) => {
245245
if (line.length > 0) {
246-
line += "\n"
246+
line += "\n";
247247
}
248248
const actualData = logFilter.filterData(line, infoLogLevel, null);
249249
const expectedData = data.infoExpectedArr[index];

0 commit comments

Comments
 (0)