Skip to content

Commit

Permalink
Clean code: remove unused constant (#28384)
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert authored Jan 5, 2025
1 parent 7ebb915 commit 8566b30
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
-%>
<%_
const tsKeyId = primaryKey.tsSampleValues[0];
const enumImports = generateEntityClientEnumImports(fields);
_%>
import { TestBed } from '@angular/core/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ type <%= entityAngularName %>FormDefaults = Pick<New<%= entityAngularName %>, '<

type <%= entityAngularName %>FormGroupContent = {
<%_ for (field of fields) {
const { fieldName, fieldType, fieldTypeBlobContent, fieldValidationRequired, tsType, fieldIsEnum } = field;
const { fieldName } = field;
_%>
<%= fieldName %>: FormControl<<%= entityFormName %>['<%= fieldName %>']<% if (field.id) { %> | New<%= entityAngularName %>['<%= fieldName %>']<% } %>>;
<%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
<%= fieldName %>ContentType: FormControl<<%= entityFormName %>['<%= fieldName %>ContentType']>;
<%_ } _%>
<%_ } _%>
<%_ for (const relationship of relationships.filter(relationship => relationship.persistableRelationship)) {
const { propertyName, otherEntity } = relationship;
const { propertyName } = relationship;
_%>
<%= propertyName %>: FormControl<<%= entityFormName %>['<%= propertyName %>']>;
<%_ } _%>
Expand Down Expand Up @@ -104,7 +104,7 @@ export class <%= entityAngularName %>FormService {

return new FormGroup<<%= entityAngularName %>FormGroupContent>({
<%_ for (const field of fields) {
const { fieldName, fieldType, fieldTypeBlobContent, fieldValidateRules, fieldTypeTemporal, fieldValidationRequired, fieldValidationMinLength, fieldValidationMaxLength, fieldValidationMin, fieldValidationMax, fieldValidationPattern } = field;
const { fieldName, fieldValidationRequired, fieldValidationMinLength, fieldValidationMaxLength, fieldValidationMin, fieldValidationMax, fieldValidationPattern } = field;
const usesValidators = fieldValidationRequired || fieldValidationMinLength || fieldValidationMaxLength || fieldValidationMin || fieldValidationMax || fieldValidationPattern || field.id;
_%>
<%= fieldName %>: new FormControl(
Expand Down Expand Up @@ -146,7 +146,7 @@ _%>
<%_ } _%>
<%_ } _%>
<%_ for (const relationship of relationships.filter(relationship => relationship.persistableRelationship)) {
const { relationshipRequired, propertyName, relationshipName, collection, otherEntity } = relationship;
const { relationshipRequired, propertyName, collection } = relationship;
_%>
<%= propertyName %>: new FormControl(
<%= entityInstance %>RawValue.<%= propertyName %><% if (collection) { %> ?? []<% } %>
Expand Down Expand Up @@ -198,7 +198,7 @@ _%>

return {
<%_ for (field of fields) {
const { fieldName, fieldTypeBoolean, fieldTypeTimed, fieldTypeLocalDate } = field;
const { fieldName, fieldTypeBoolean, fieldTypeTimed } = field;
_%>
<%_ if (field.fieldTsDefaultValue) { _%>
<%= fieldName %>: <%- field.fieldTsDefaultValue %>,
Expand All @@ -213,7 +213,7 @@ _%>
<%_ } _%>
<%_ } _%>
<%_ for (const relationship of relationships.filter(({ persistableRelationship }) => persistableRelationship)) {
const { relationshipRequired, propertyName, collection, otherEntity, relationshipName } = relationship;
const { propertyName, collection } = relationship;
_%>
<%_ if (collection) { _%>
<%= propertyName %>: [],
Expand Down Expand Up @@ -248,7 +248,7 @@ _%>
<%_ } _%>
<%_ } _%>
<%_ for (const relationship of relationships.filter(({ persistableRelationship }) => persistableRelationship)) {
const { relationshipRequired, propertyName, collection } = relationship;
const { propertyName, collection } = relationship;
_%>
<%_ if (collection) { _%>
<%= propertyName %>: <%= entityInstance %>.<%= propertyName %> ?? [],
Expand Down
39 changes: 0 additions & 39 deletions generators/bootstrap-application-base/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,6 @@ const { CommonDBTypes } = fieldTypes;

const { STRING: TYPE_STRING, BOOLEAN: TYPE_BOOLEAN, INSTANT } = CommonDBTypes;

Check warning on line 32 in generators/bootstrap-application-base/utils.ts

View workflow job for this annotation

GitHub Actions / check-npm-test

'INSTANT' is assigned a value but never used. Allowed unused vars must match /^_[^_]/u

export const auditableEntityFields = () => [
{
fieldName: 'createdBy',
fieldType: TYPE_STRING,
readonly: true,
skipServer: true,
builtIn: true,
fieldValidateRules: [Validations.MAXLENGTH],
fieldValidateRulesMaxlength: 50,
autoGenerate: true,
},
{
fieldName: 'createdDate',
fieldType: INSTANT,
readonly: true,
skipServer: true,
builtIn: true,
autoGenerate: true,
},
{
fieldName: 'lastModifiedBy',
fieldType: TYPE_STRING,
readonly: true,
skipServer: true,
builtIn: true,
fieldValidateRules: [Validations.MAXLENGTH],
fieldValidateRulesMaxlength: 50,
autoGenerate: true,
},
{
fieldName: 'lastModifiedDate',
fieldType: INSTANT,
readonly: true,
skipServer: true,
builtIn: true,
autoGenerate: true,
},
];

const authorityEntityName = 'Authority';

export function createUserEntity(this: BaseApplicationGenerator, customUserData = {}, application): Partial<UserEntity> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ package <%= entityAbsolutePackage %>.service;
<%_
const serviceClassName = entityClass + 'QueryService';
const instanceType = restClass;
const instanceName = restInstance;
const mapper = entityInstance + 'Mapper';
const dtoToEntity = mapper + '.'+ 'toEntity';
const entityToDto = mapper + '.'+ 'toDto';
const entityListToDto = mapper + '.' + 'toDto';
const entityToDtoReference = mapper + '::'+ 'toDto';
const repository = entityInstance + 'Repository';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ const optionalOrMono = (reactive) ? 'Mono' : 'Optional';
const listOrFlux = (reactive) ? 'Flux' : 'List';
const pageOrFlux = (reactive) ? 'Flux' : 'Page';
const mapper = entityInstance + 'Mapper';
const dtoToEntity = mapper + '.'+ 'toEntity';
const entityToDto = 'toDto';
const entityToDtoReference = mapper + '::'+ 'toDto';
const repository = entityInstance + 'Repository';
const searchRepository = entityInstance + 'SearchRepository';

_%>
<%_ if (serviceImpl) { _%>
Expand Down

0 comments on commit 8566b30

Please sign in to comment.