Skip to content

Commit

Permalink
Clean up validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gitKrystan committed Jan 24, 2023
1 parent 067b0e8 commit 8b85cdc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion transforms/helpers/eo-prop/private/call-expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class EOCallExpressionProp extends AbstractEOProp<EOPropertyWithC
}
}

private get calleeName(): string {
get calleeName(): string {
return this.calleeObject.callee.name;
}

Expand Down
5 changes: 4 additions & 1 deletion transforms/helpers/log-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const logFormatter = printf((info) => {

const logger = createLogger({
format: combine(timestamp(), logFormatter),
transports: [new transports.File({ filename: 'codemods.log' })],
// FIXME: Revert
transports: [
new transports.File({ filename: 'codemods.log', level: 'error' }),
],
});

export default logger;
8 changes: 4 additions & 4 deletions transforms/helpers/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export default function maybeTransformEmberObjects(
userOptions: UserOptions
): boolean | undefined {
if (isTestFile(filePath)) {
logger.warn(`[${filePath}]: Skipping test file`);
logger.warn(`[${filePath}]: SKIPPED: test file`);
return;
}

if (userOptions.type && !isFileOfType(filePath, userOptions.type)) {
logger.warn(
`[${filePath}]: FAILURE Type mismatch, expected type '${userOptions.type}' did not match type of file`
`[${filePath}]: SKIPPED: Type mismatch, expected type '${userOptions.type}' did not match type of file`
);
return;
}
Expand All @@ -46,7 +46,7 @@ export default function maybeTransformEmberObjects(
: getTelemetryFor(path.resolve(filePath));
if (!runtimeData || !isRuntimeData(runtimeData)) {
logger.warn(
`[${filePath}]: SKIPPED Could not find runtime data NO_RUNTIME_DATA`
`[${filePath}]: SKIPPED: Could not find runtime data NO_RUNTIME_DATA`
);
return;
}
Expand Down Expand Up @@ -123,7 +123,7 @@ function _maybeTransformEmberObjects(
}

if (errors.length > 0) {
logger.warn(
logger.error(
`[${filePath}]: FAILURE \nValidation errors: \n\t${errors.join(
'\n\t'
)}`
Expand Down
24 changes: 17 additions & 7 deletions transforms/helpers/validation-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,29 @@ export function hasValidProps(
}

if (
(!decorators &&
(instanceProp.hasDecorators ||
instanceProp instanceof EOClassDecoratorProp)) ||
unsupportedPropNames.includes(instanceProp.name) ||
(instanceProp instanceof EOCallExpressionProp &&
!instanceProp.hasDecorators)
!decorators &&
(instanceProp.hasDecorators ||
instanceProp instanceof EOClassDecoratorProp ||
instanceProp instanceof EOCallExpressionProp)
) {
errors.push(
`[${instanceProp.name}]: Transform not supported - need option '--decorators=true' or the property type ${instanceProp.type} can not be transformed`
`[${instanceProp.name}]: Transform not supported - need option '--decorators=true'`
);
}

if (unsupportedPropNames.includes(instanceProp.name)) {
errors.push(
`[${instanceProp.name}]: Transform not supported - property with name '${instanceProp.name}' and type ${instanceProp.type} can not be transformed`
);
}

if (instanceProp instanceof EOCallExpressionProp) {
if (!instanceProp.hasDecorators) {
errors.push(
`[${instanceProp.name}]: Transform not supported - call to '${instanceProp.calleeName}' can not be transformed`
);
}

if (instanceProp.hasModifierWithArgs) {
errors.push(
`[${instanceProp.name}]: Transform not supported - value has modifiers like 'property' or 'meta'`
Expand Down

0 comments on commit 8b85cdc

Please sign in to comment.