Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup function parameters and possible undefined #137

Closed
3 tasks done
ryanluker opened this issue Jun 11, 2018 · 0 comments · Fixed by #139
Closed
3 tasks done

Cleanup function parameters and possible undefined #137

ryanluker opened this issue Jun 11, 2018 · 0 comments · Fixed by #139
Labels
Milestone

Comments

@ryanluker
Copy link
Owner

ryanluker commented Jun 11, 2018

Based on error reporting version 2.0.0 has had a few crashes in these two functions, mostly undefined errors.

Check intersection being undefined before using reverse

private findIntersect(base: string, comparee: string): string {
const a = [...base].reverse();
const b = [...comparee].reverse();
// find the intersection and reverse it back into a string
const intersection: string[] = [];
let pos = 0;
// stop when strings at pos are no longer are equal
while (a[pos] === b[pos]) {
// if we reached the end or there isnt a value for that pos
// exit the while loop
if (!a[pos] || !b[pos]) { break; }
intersection.push(a[pos]);
pos++;
}
const subInt = intersection.reverse().join("");
return subInt;
}

Check filename / name being undefined before manipulating

private normalizeFileName(fileName: string): string {
let name = fileName;
// make file path relative and OS independent
name = name.toLocaleLowerCase();
// remove all file slashes
name = name.replace(/\//g, "###");
name = name.replace(/\\/g, "###");
return name;
}

Work:

  • failing unit tests for above errors
  • add proper ts types for the api (currently assume fileName: string when maybe it should be fileName: string | undefined)
  • handle undefineds
@ryanluker ryanluker added this to the 2.1.0 milestone Jun 11, 2018
@ryanluker ryanluker added the bug label Jun 11, 2018
@ryanluker ryanluker assigned ryanluker and unassigned ryanluker Jun 29, 2018
ryanluker pushed a commit that referenced this issue Jul 2, 2018
… errors

* Adding strict null checks compiler option and fixing resulting errors.

* wip

* use any to make tests sane

* Fix 'undefined' issues in merge.

* Removing test that fails intermittently.
@ryanluker ryanluker reopened this Jul 2, 2018
brandongk added a commit that referenced this issue Jul 3, 2018
#137 - Splitting TopSectionFinder from Renderer and adding unit tests to both. (WIP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant