-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core: remove last debugString references #5856
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,21 +37,21 @@ const ALLOWED_ORIENTATION_VALUES = [ | |
*/ | ||
function parseString(raw, trim) { | ||
let value; | ||
let debugString; | ||
let warning; | ||
|
||
if (typeof raw === 'string') { | ||
value = trim ? raw.trim() : raw; | ||
} else { | ||
if (raw !== undefined) { | ||
debugString = 'ERROR: expected a string.'; | ||
warning = 'ERROR: expected a string.'; | ||
} | ||
value = undefined; | ||
} | ||
|
||
return { | ||
raw, | ||
value, | ||
debugString, | ||
warning, | ||
}; | ||
} | ||
|
||
|
@@ -70,7 +70,7 @@ function parseColor(raw) { | |
const validatedColor = validateColor(color.raw); | ||
if (!validatedColor) { | ||
color.value = undefined; | ||
color.debugString = 'ERROR: color parsing failed.'; | ||
color.warning = 'ERROR: color parsing failed.'; | ||
} | ||
|
||
return color; | ||
|
@@ -117,7 +117,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { | |
return { | ||
raw, | ||
value: documentUrl, | ||
debugString: 'ERROR: start_url string empty', | ||
warning: 'ERROR: start_url string empty', | ||
}; | ||
} | ||
const parsedAsString = parseString(raw); | ||
|
@@ -135,7 +135,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { | |
return { | ||
raw, | ||
value: documentUrl, | ||
debugString: 'ERROR: invalid start_url relative to ${manifestUrl}', | ||
warning: 'ERROR: invalid start_url relative to ${manifestUrl}', | ||
}; | ||
} | ||
|
||
|
@@ -144,7 +144,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { | |
return { | ||
raw, | ||
value: documentUrl, | ||
debugString: 'ERROR: start_url must be same-origin as document', | ||
warning: 'ERROR: start_url must be same-origin as document', | ||
}; | ||
} | ||
|
||
|
@@ -165,7 +165,7 @@ function parseDisplay(jsonInput) { | |
return { | ||
raw: jsonInput, | ||
value: DEFAULT_DISPLAY_MODE, | ||
debugString: parsedString.debugString, | ||
warning: parsedString.warning, | ||
}; | ||
} | ||
|
||
|
@@ -174,15 +174,15 @@ function parseDisplay(jsonInput) { | |
return { | ||
raw: jsonInput, | ||
value: DEFAULT_DISPLAY_MODE, | ||
debugString: 'ERROR: \'display\' has invalid value ' + displayValue + | ||
warning: 'ERROR: \'display\' has invalid value ' + displayValue + | ||
`. will fall back to ${DEFAULT_DISPLAY_MODE}.`, | ||
}; | ||
} | ||
|
||
return { | ||
raw: jsonInput, | ||
value: displayValue, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -195,7 +195,7 @@ function parseOrientation(jsonInput) { | |
if (orientation.value && | ||
!ALLOWED_ORIENTATION_VALUES.includes(orientation.value.toLowerCase())) { | ||
orientation.value = undefined; | ||
orientation.debugString = 'ERROR: \'orientation\' has an invalid value, will be ignored.'; | ||
orientation.warning = 'ERROR: \'orientation\' has an invalid value, will be ignored.'; | ||
} | ||
|
||
return orientation; | ||
|
@@ -223,13 +223,13 @@ function parseIcon(raw, manifestUrl) { | |
raw: raw.density, | ||
value: 1, | ||
/** @type {string|undefined} */ | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
if (density.raw !== undefined) { | ||
density.value = parseFloat(density.raw); | ||
if (isNaN(density.value) || !isFinite(density.value) || density.value <= 0) { | ||
density.value = 1; | ||
density.debugString = 'ERROR: icon density cannot be NaN, +∞, or less than or equal to +0.'; | ||
density.warning = 'ERROR: icon density cannot be NaN, +∞, or less than or equal to +0.'; | ||
} | ||
} | ||
|
||
|
@@ -242,7 +242,7 @@ function parseIcon(raw, manifestUrl) { | |
sizes = { | ||
raw: raw.sizes, | ||
value: set.size > 0 ? Array.from(set) : undefined, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} else { | ||
sizes = {...parsedSizes, value: undefined}; | ||
|
@@ -256,7 +256,7 @@ function parseIcon(raw, manifestUrl) { | |
density, | ||
sizes, | ||
}, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -272,7 +272,7 @@ function parseIcons(jsonInput, manifestUrl) { | |
raw, | ||
/** @type {Array<ReturnType<typeof parseIcon>>} */ | ||
value: [], | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -281,7 +281,7 @@ function parseIcons(jsonInput, manifestUrl) { | |
raw, | ||
/** @type {Array<ReturnType<typeof parseIcon>>} */ | ||
value: [], | ||
debugString: 'ERROR: \'icons\' expected to be an array but is not.', | ||
warning: 'ERROR: \'icons\' expected to be an array but is not.', | ||
}; | ||
} | ||
|
||
|
@@ -298,7 +298,7 @@ function parseIcons(jsonInput, manifestUrl) { | |
return { | ||
raw, | ||
value, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -317,7 +317,7 @@ function parseApplication(raw) { | |
appUrl.value = new URL(appUrl.value).href; | ||
} catch (e) { | ||
appUrl.value = undefined; | ||
appUrl.debugString = 'ERROR: invalid application URL ${raw.url}'; | ||
appUrl.warning = 'ERROR: invalid application URL ${raw.url}'; | ||
} | ||
} | ||
|
||
|
@@ -328,7 +328,7 @@ function parseApplication(raw) { | |
id, | ||
url: appUrl, | ||
}, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -342,15 +342,15 @@ function parseRelatedApplications(jsonInput) { | |
return { | ||
raw, | ||
value: undefined, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
if (!Array.isArray(raw)) { | ||
return { | ||
raw, | ||
value: undefined, | ||
debugString: 'ERROR: \'related_applications\' expected to be an array but is not.', | ||
warning: 'ERROR: \'related_applications\' expected to be an array but is not.', | ||
}; | ||
} | ||
|
||
|
@@ -364,7 +364,7 @@ function parseRelatedApplications(jsonInput) { | |
return { | ||
raw, | ||
value, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -374,21 +374,21 @@ function parseRelatedApplications(jsonInput) { | |
function parsePreferRelatedApplications(jsonInput) { | ||
const raw = jsonInput.prefer_related_applications; | ||
let value; | ||
let debugString; | ||
let warning; | ||
|
||
if (typeof raw === 'boolean') { | ||
value = raw; | ||
} else { | ||
if (raw !== undefined) { | ||
debugString = 'ERROR: \'prefer_related_applications\' expected to be a boolean.'; | ||
warning = 'ERROR: \'prefer_related_applications\' expected to be a boolean.'; | ||
} | ||
value = undefined; | ||
} | ||
|
||
return { | ||
raw, | ||
value, | ||
debugString, | ||
warning, | ||
}; | ||
} | ||
|
||
|
@@ -425,7 +425,7 @@ function parse(string, manifestUrl, documentUrl) { | |
return { | ||
raw: string, | ||
value: undefined, | ||
debugString: 'ERROR: file isn\'t valid JSON: ' + e, | ||
warning: 'ERROR: file isn\'t valid JSON: ' + e, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @paulirish wanted this to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (it will be interesting to see if you change it just here (and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh meant to reply to this, this was an intentional feigned ignorance about that part of the comment ;) I don't think manifest-parser should to try to name its properties based on how one audit will pass/fail because of its Since we're taking the stance that these are all warnings and not total failures, seems like we should lean in to it :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on the one hand.. this field represents why the manifest parser was unable to parse. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol, I'd prefer it given the agreement we have around everything else in there labelled sg! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I also agree with this. It's the only real failure for a manifest. Everything else is a warning that something was malformed but the browser will fall back to a default, so the manifest will still work. But I also don't care that much :) it's just (minor) ergonomics of the result, not correctness. |
||
}; | ||
} | ||
|
||
|
@@ -447,7 +447,7 @@ function parse(string, manifestUrl, documentUrl) { | |
return { | ||
raw: string, | ||
value: manifest, | ||
debugString: undefined, | ||
warning: undefined, | ||
}; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like we want the
manifest-parser
still returning something likedebugString
?explanation
seems too generic for what is always indicating an error/warning. Gatherers that use it would still only use the standard thingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally in
manifest-parser
it waswarning
, which got switched todebugString
, which was then spread throughout Lighthouse cause why not, all in #102 :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds like you're upset with our decision to use
explanation
period :)I'm not 100% sure what you're advocating for, is it for this PR to just remove the TODO and fix the tests then since we don't want to pursue it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, well,
explanation
on an audit is a little confusing in isolation (we really should add a jsdoc description to it inaudit.d.ts
:), but it comes in the context of a failing audit.In this case the only indication that there was an issue is the existence of the string. I meant just for
manifest-parser.js
, it's not in the gatherer or audit pipelines, it's just a lib file, so it seems fine to have a more descriptive property name specific to that file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looked and within manifest-parser, i'd say that, semantically, all these properties are really
warning
s. Except for theerrorMessage
at the end about invalid JSONSo i'd be in favor of changing the manifestparser explanation->warning for all items and errorMesssage on the toplevel. and also tweaking manifest-values.js to use these terms as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendankenny are you on board with
warning
as well? I think it reads rather well now (aside from the fact that it'swarning = 'ERROR:
😆)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, sounds good to me
lol yes, that's terrible