Skip to content

Commit

Permalink
Merge pull request #2 from YamanQD/master
Browse files Browse the repository at this point in the history
Improve codefactor.io code quality rating
  • Loading branch information
Rami-Sabbagh authored Jul 2, 2021
2 parents a548473 + 1062507 commit 8b59810
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
uses: actions/[email protected]
with:
node-version: 14.x

- name: Install the dependencies
run: yarn

- name: Generate the documentation
run: yarn docs

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function extractMarksFromDocument(document: PDFDocumentProxy): Prom

/**
* Loads a PDF document and extracts the marks records from it.
*
*
* @param src Can be a URL where a PDF file is located, a typed array (Uint8Array)
* already populated with data, or a parameter object.
* @returns The extracted marks records.
Expand Down
16 changes: 8 additions & 8 deletions src/items-merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { SimpleTextItem } from './simple-text-item';

/**
* Represents a row of sorted items, which can be iterated for each item.
*
*
* The items are sorted in ascending order by their X coordinates (which is page-left based).
*
*
* This is essential for the items merging algorithm.
*/
class SortedRow implements Iterable<SimpleTextItem> {

/**
* Construct a new row of items view.
*
*
* @param items The items array to take a section from,
* it should be sorted in ascending order by Y coordinates then by X coordinates.
* @param fromIndex The index of the first item included in the view section.
Expand All @@ -38,9 +38,9 @@ class SortedRow implements Iterable<SimpleTextItem> {

/**
* Represents a page of sorted items, which can be iterated for each row of items.
*
*
* The items rows are sorted in ascending order by their Y coordinates (which is page-bottom based).
*
*
* This is essential for the items merging algorithm.
*/
class SortedPage implements Iterable<SortedRow> {
Expand Down Expand Up @@ -84,7 +84,7 @@ class SortedPage implements Iterable<SortedRow> {

/**
* Checks whether the item is protected from being merged with other items or not.
*
*
* @param item The item to check.
* @returns Whether the item is protected or not.
*/
Expand All @@ -95,7 +95,7 @@ function isItemProtected(item: SimpleTextItem): boolean {

/**
* Checks whether 2 items should be merged or not.
*
*
* @param itemA The first item to check, which should be to the left (lower X coordinates).
* @param itemB The second item to check, which should be to the right (higher X cordinates).
* @returns Whether the items should be merged or not.
Expand All @@ -112,7 +112,7 @@ function shouldBeMerged(itemA: SimpleTextItem, itemB: SimpleTextItem): boolean {
/**
* Merges close Arabic simplified text items into single items.
* The original list is left unmodified.
*
*
* @param items The list of simplified text items.
* @returns A new list of the text items after merging close Arabic items.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/items-shaper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TablePage implements Iterable<SimpleTextItem[]> {

/**
* Checks if the projects of 2 items on the Y axis intersect.
*
*
* @param itemA The first item to check.
* @param itemB The second item to check.
* @returns Whether their projections on the Y axis intersect or not.
Expand All @@ -60,7 +60,7 @@ class TablePage implements Iterable<SimpleTextItem[]> {

/**
* Groups the list of items into a table structure.
*
*
* @param items The target list of simplified text items.
* @returns A 2-dimensional array of the text items,
* where the first dimension is for the able rows,
Expand Down
2 changes: 1 addition & 1 deletion src/mark-record.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Represents a mark record extracted from the document.
*
*
* All the fields (except the `studentId`) can be `null` because they might be missing from the table, or malformed with other values.
*/
export interface MarkRecord {
Expand Down
6 changes: 3 additions & 3 deletions src/marks-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MarkRecord } from './mark-record';

/**
* Extracts marks records from a table of simplified text items.
*
*
* @param itemsTable The simplified items table to extract marks from.
* @returns The extracted marks records.
*/
Expand All @@ -19,7 +19,7 @@ export function extractMarksFromItemsTable(itemsTable: readonly (readonly Readon

// Create the record.
const record: MarkRecord = {
studentId: Number.parseInt(studentIdItem.value),
studentId: Number.parseInt(studentIdItem.value, 10),
studentName: null,
studentFatherName: null,
practicalMark: null,
Expand All @@ -43,7 +43,7 @@ export function extractMarksFromItemsTable(itemsTable: readonly (readonly Readon
else if (record.studentFatherName === null) record.studentFatherName = value.trim();
}

if (isMark && marks.length < 3) marks.push(Number.parseInt(value));
if (isMark && marks.length < 3) marks.push(Number.parseInt(value, 10));
}

if (marks.length === 1)
Expand Down

0 comments on commit 8b59810

Please sign in to comment.