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

Bug fixes #113

Merged
merged 8 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ There is provision for checking to be altered and/or sped-up when the calling ap
- `taRepoLanguageCode`, and `taRepoSectionName`: can be used to specify how the `SupportReference` field is checked in TA—defaults are 'en' and 'translate'
- `twRepoUsername`, `twRepoBranchName`: these two fields can be used to specify the username/organisation and/or the branch/tag name for fetching the TW files for checking
- `extractLength`: an integer which defines how long excerpts of lines containing errors should be—the default is 15 characters—the package attempts to place the error in the middle of the extract
- `cutoffPriorityLevel`: an integer which can define notices to not be detected—defaults to 0 so none are dropped. Note that this will also affect the `suggestion` response.
- `cutoffPriorityLevel`: an integer which can define notices to not be detected—defaults to 0 so none are dropped. Note that this will also affect the `suggestion` response. (Only partially implemented at present, so drops some but not all low priority notices.)
- `suppressNoticeDisablingFlag`: Defaults to `false`, i.e., to removing (thus suppressing) notices for warnings which are expected in certain files and hence we don’t want them displayed. Note that this is always set to `true` for the demos (because they suppress these notices later—see the `showDisabledNoticesFlag` below).

Currently this supressing is only done in the (exported) `checkTN_TSVText` and `checkAnnotationRows` functions which we know to be called by [tC Create](https://github.com/unfoldingWord/tc-create-app) as well as `checkManifestText`, `checkMarkdownText`, `checkPlainText`, `checkTN_TSVText`, `checkUSFMText`, and `checkYAMLText` called by the [Content Validation App](https://github.com/unfoldingWord-box3/content-validation-app).
Expand Down Expand Up @@ -155,7 +155,7 @@ Known bugs:
Known check deficiencies:

1. Markdown image format `![xx](yy)` is not yet fully checked
1. Filenames in manifests are not fully checked
1. Manifests are not checked against all files, i.e., to find files potentially missing from the manifest
1. Naked HTTP links are not yet checked properly
1. ULT/UST quotes in TranslationAcademy are not yet checked

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "uw-content-validation",
"description": "Functions for Checking Door43.org Scriptural Content/Resources.",
"version": "0.9.3",
"version": "1.0.0",
"private": false,
"homepage": "https://unfoldingword.github.io/uw-content-validation/",
"repository": {
Expand Down
24 changes: 0 additions & 24 deletions src/__tests__/__snapshots__/book-package-check.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,6 @@ Object {
"repoName": "hbo_uhb",
"username": "unfoldingWord",
},
Object {
"bookID": "RUT",
"details": "username=unfoldingWord error=Could not find src/__tests__/fixtures/unfoldingWord/en_twl/RUT_twl.tsv",
"extra": "TWL",
"filename": "RUT_twl.tsv",
"location": " in TWL in en RUT book package from unfoldingWord master branch",
"message": "Unable to load",
"priority": 996,
"repoCode": "TWL",
"repoName": "en_twl",
"username": "unfoldingWord",
},
Object {
"C": "2",
"V": "1",
Expand Down Expand Up @@ -7172,18 +7160,6 @@ Object {
"en_tq",
],
"noticeList": Array [
Object {
"bookID": "TIT",
"details": "username=unfoldingWord error=Could not find src/__tests__/fixtures/unfoldingWord/en_twl/TIT_twl.tsv",
"extra": "TWL",
"filename": "TIT_twl.tsv",
"location": " in TWL in en TIT book package from unfoldingWord master branch",
"message": "Unable to load",
"priority": 996,
"repoCode": "TWL",
"repoName": "en_twl",
"username": "unfoldingWord",
},
Object {
"C": "1",
"V": "1",
Expand Down
2 changes: 1 addition & 1 deletion src/core/manifest-text-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Ajv from 'ajv';
import { removeDisabledNotices } from './disabled-notices';


const MANIFEST_VALIDATOR_VERSION_STRING = '0.3.7';
const MANIFEST_VALIDATOR_VERSION_STRING = '0.4.0';

// Pasted in 2020-10-02 from https://raw.githubusercontent.com/unfoldingWord/dcs/master/options/schema/rc.schema.json
const MANIFEST_SCHEMA = {
Expand Down
10 changes: 5 additions & 5 deletions src/demos/book-package-check/checkBookPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { checkFileContents } from '../file-check/checkFileContents';
import { checkRepo } from '../repo-check/checkRepo';


// const BP_VALIDATOR_VERSION_STRING = '0.5.2';
// const BP_VALIDATOR_VERSION_STRING = '0.5.3';

const MANIFEST_FILENAME = 'manifest.yaml';

Expand Down Expand Up @@ -46,7 +46,7 @@ export async function checkBookPackage(username, languageCode, bookID, setResult
let checkedFileCount = 0, checkedFilenames = [], checkedFilenameExtensions = new Set(), totalCheckedSize = 0, checkedRepoNames = new Set();
let checkBookPackageResult = { successList: [], noticeList: [] };

let dataSet = checkingOptions.dataSet; // Can be 'DEFAULT', 'OLD' (Markdown, etc.), 'NEW' (TSV only), or 'BOTH'
let dataSet = checkingOptions?.dataSet; // Can be 'DEFAULT', 'OLD' (Markdown, etc.), 'NEW' (TSV only), or 'BOTH'
if (!dataSet) dataSet = 'DEFAULT';

const newCheckingOptions = checkingOptions ? { ...checkingOptions } : {}; // clone before modify
Expand Down Expand Up @@ -112,7 +112,7 @@ export async function checkBookPackage(username, languageCode, bookID, setResult
console.assert(typeof fileLocation === 'string', `cBP ourCheckBPFileContents: 'fileLocation' parameter should be a string not a '${typeof fileLocation}'`);
console.assert(checkingOptions !== undefined, "cBP ourCheckBPFileContents: 'checkingOptions' parameter should be defined");

const cfcResultObject = await checkFileContents(languageCode, repoCode, cfFilename, fileContent, fileLocation, checkingOptions);
const cfcResultObject = await checkFileContents(username, languageCode, repoCode, cfFilename, fileContent, fileLocation, checkingOptions);
// console.log("checkFileContents() returned", cfResultObject.successList.length, "success message(s) and", cfResultObject.noticeList.length, "notice(s)");
// for (const successEntry of cfResultObject.successList) console.log(" ourCheckBPFileContents:", successEntry);
// console.log("cfcResultObject", JSON.stringify(cfcResultObject));
Expand Down Expand Up @@ -288,7 +288,7 @@ export async function checkBookPackage(username, languageCode, bookID, setResult
// So now we want to work through checking this one specified Bible book in various repos
const origLangRepoCode = whichTestament === 'old' ? 'UHB' : 'UGNT';
if (dataSet === 'DEFAULT')
repoCodeList = languageCode === 'en' ? [origLangRepoCode, 'TWL', 'LT', 'ST', 'TN', 'TQ'] : [origLangRepoCode, 'TWL', 'LT', 'ST', 'TN', 'TQ'];
repoCodeList = languageCode === 'en' ? [origLangRepoCode, 'LT', 'ST', 'TN', 'TQ'] : [origLangRepoCode, 'LT', 'ST', 'TN', 'TQ'];
else if (dataSet === 'OLD')
repoCodeList = languageCode === 'en' ? [origLangRepoCode, 'LT', 'ST', 'TN', 'TQ'] : [origLangRepoCode, 'LT', 'ST', 'TN', 'TQ'];
else if (dataSet === 'NEW')
Expand Down Expand Up @@ -509,7 +509,7 @@ async function checkTQMarkdownBook(username, languageCode, repoName, branch, boo
console.assert(typeof fileLocation === 'string', `cTQ ourCheckTQFileContents: 'fileLocation' parameter should be a string not a '${typeof fileLocation}'`);
console.assert(checkingOptions !== undefined, "cTQ ourCheckTQFileContents: 'checkingOptions' parameter should be defined");

const cfResultObject = await checkFileContents(languageCode, repoCode, cfFilename, fileContent, fileLocation, checkingOptions);
const cfResultObject = await checkFileContents(username, languageCode, repoCode, cfFilename, fileContent, fileLocation, checkingOptions);
// console.log("checkFileContents() returned", cfResultObject.successList.length, "success message(s) and", cfResultObject.noticeList.length, "notice(s)");
// for (const successEntry of cfResultObject.successList) console.log(" ourCheckTQFileContents:", successEntry);

Expand Down
2 changes: 1 addition & 1 deletion src/demos/file-check/FileCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function FileCheck(props) {
else if (repoName.endsWith('lt')) repoCodeGuess = 'LT'
else if (repoName.endsWith('st')) repoCodeGuess = 'ST'

rawCFResults = await checkFileContents(languageCode, repoCodeGuess, filename, fileContent, givenLocation, checkingOptions);
rawCFResults = await checkFileContents(username, languageCode, repoCodeGuess, filename, fileContent, givenLocation, checkingOptions);

// Because we know here that we're only checking one file, we don’t need the filename field in the notices
// WRONG: We want the filename so that the lineNumber can be made into a live link
Expand Down
21 changes: 12 additions & 9 deletions src/demos/file-check/checkFileContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as books from '../../core/books/books';
import { formRepoName, checkUSFMText, checkMarkdownFileContents, checkPlainText, checkYAMLText, checkManifestText, checkTN_TSVText, checkAnnotationRows } from '../../core';


// const CHECK_FILE_CONTENTS_VERSION_STRING = '0.2.3';
// const CHECK_FILE_CONTENTS_VERSION_STRING = '0.3.0';


/**
Expand All @@ -13,20 +13,22 @@ import { formRepoName, checkUSFMText, checkMarkdownFileContents, checkPlainText,
* @param {string} givenLocation
* @param {Object} checkingOptions
*/
export async function checkFileContents(languageCode, repoCode, filename, fileContent, givenLocation, checkingOptions) {
export async function checkFileContents(username, languageCode, repoCode, filename, fileContent, givenLocation, checkingOptions) {
// Determine the file type from the filename extension
// and return the results of checking that kind of file text
// console.log(`checkFileContents(${languageCode}, ${filename}, ${fileContent.length} chars, ${givenLocation}, ${JSON.stringify(checkingOptions)})…`);
// console.log(`checkFileContents(${username}, ${languageCode}, ${filename}, ${fileContent.length} chars, ${givenLocation}, ${JSON.stringify(checkingOptions)})…`);
console.assert(username !== undefined, "checkFileContents: 'username' parameter should be defined");
console.assert(typeof username === 'string', `checkFileContents: 'username' parameter should be a string not a '${typeof username}': ${username}`);
console.assert(languageCode !== undefined, "checkFileContents: 'languageCode' parameter should be defined");
console.assert(typeof languageCode === 'string', `checkFileContents: 'languageCode' parameter should be a string not a '${typeof languageCode}'`);
console.assert(typeof languageCode === 'string', `checkFileContents: 'languageCode' parameter should be a string not a '${typeof languageCode}': ${languageCode}`);
console.assert(repoCode !== undefined, "checkFileContents: 'repoCode' parameter should be defined");
console.assert(typeof repoCode === 'string', `checkFileContents: 'repoCode' parameter should be a string not a '${typeof repoCode}'`);
console.assert(typeof repoCode === 'string', `checkFileContents: 'repoCode' parameter should be a string not a '${typeof repoCode}': ${repoCode}`);
console.assert(filename !== undefined, "checkFileContents: 'filename' parameter should be defined");
console.assert(typeof filename === 'string', `checkFileContents: 'filename' parameter should be a string not a '${typeof filename}'`);
console.assert(typeof filename === 'string', `checkFileContents: 'filename' parameter should be a string not a '${typeof filename}': ${filename}`);
console.assert(fileContent !== undefined, "checkFileContents: 'fileContent' parameter should be defined");
console.assert(typeof fileContent === 'string', `checkFileContents: 'fileContent' parameter should be a string not a '${typeof fileContent}'`);
console.assert(typeof fileContent === 'string', `checkFileContents: 'fileContent' parameter should be a string not a '${typeof fileContent}': ${fileContent.length}`);
console.assert(givenLocation !== undefined, "checkFileContents: 'givenRowLocation' parameter should be defined");
console.assert(typeof givenLocation === 'string', `checkFileContents: 'givenRowLocation' parameter should be a string not a '${typeof givenLocation}'`);
console.assert(typeof givenLocation === 'string', `checkFileContents: 'givenRowLocation' parameter should be a string not a '${typeof givenLocation}': ${givenLocation}`);
console.assert(checkingOptions !== undefined, "checkFileContents: 'checkingOptions' parameter should be defined");

const startTime = new Date();
Expand Down Expand Up @@ -69,7 +71,8 @@ export async function checkFileContents(languageCode, repoCode, filename, fileCo
else if (filenameLower.endsWith('.txt'))
checkFileResult = checkPlainText('text', filename, fileContent, ourCFLocation, checkingOptions);
else if (filenameLower === 'manifest.yaml')
checkFileResult = await checkManifestText('', formRepoName(languageCode, repoCode), '', fileContent, ourCFLocation, checkingOptions); // don’t know username or branch
// TODO: Does the branch need to be passed in as a parameter???
checkFileResult = await checkManifestText(username, formRepoName(languageCode, repoCode), 'master', fileContent, ourCFLocation, checkingOptions); // don’t know username or branch
else if (filenameLower.endsWith('.yaml'))
checkFileResult = checkYAMLText(languageCode, filename, fileContent, ourCFLocation, checkingOptions);
else {
Expand Down
2 changes: 1 addition & 1 deletion src/demos/repo-check/checkRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export async function checkRepo(username, repoName, branch, givenLocation, setRe
console.assert(typeof fileLocation === 'string', `ourCheckRepoFileContents: 'fileLocation' parameter should be a string not a '${typeof fileLocation}'`);
console.assert(checkingOptions !== undefined, "ourCheckRepoFileContents: 'checkingOptions' parameter should be defined");

const cfcResultObject = await checkFileContents(languageCode, repoCode, filename, fileContent, fileLocation, checkingOptions);
const cfcResultObject = await checkFileContents(username, languageCode, repoCode, filename, fileContent, fileLocation, checkingOptions);
// console.log("checkFileContents() returned", resultObject.successList.length, "success message(s) and", resultObject.noticeList.length, "notice(s)");
// for (const successEntry of resultObject.successList)
// console.log(" ", successEntry);
Expand Down
Loading