From 14e7bdd0763c7a3cd25c45e36ca213bed8fef169 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:35:25 +0200 Subject: [PATCH 01/11] models/team: Remove unnecessary `this.get()` calls --- app/models/team.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/team.js b/app/models/team.js index 48686754fdb..649d368f18a 100644 --- a/app/models/team.js +++ b/app/models/team.js @@ -18,8 +18,7 @@ export default class Team extends Model { org_name; @computed('name', 'org_name', function () { - let { name, org_name } = this.getProperties('name', 'org_name'); - return `${org_name}/${name}`; + return `${this.org_name}/${this.name}`; }) display_name; } From cd235bcda7e338cf91fd8d0b1f600b26d1e58461 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:37:32 +0200 Subject: [PATCH 02/11] models/version: Remove unnecessary `this.get()` calls --- app/models/version.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/version.js b/app/models/version.js index 25eafa70f4f..59964c95be4 100644 --- a/app/models/version.js +++ b/app/models/version.js @@ -29,7 +29,8 @@ export default class Version extends Model { @alias('loadAuthorsTask.last.value') authorNames; @(task(function* () { - let authors = yield this.get('authors'); + // trigger the async relationship to load the content + let authors = yield this.authors; return authors.meta.names; }).keepLatest()) loadAuthorsTask; @@ -39,7 +40,8 @@ export default class Version extends Model { @alias('loadDepsTask.last.value.dev') devDependencies; @(task(function* () { - let dependencies = yield this.get('dependencies'); + // trigger the async relationship to load the content + let dependencies = yield this.dependencies; let normal = dependencies.filterBy('kind', 'normal').uniqBy('crate_id'); let build = dependencies.filterBy('kind', 'build').uniqBy('crate_id'); From 9cac9ac57da77fd98252ef32eb35ed329766cc0a Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:33:45 +0200 Subject: [PATCH 03/11] dashboard: Remove unnecessary `this.get()` calls --- app/controllers/dashboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/dashboard.js b/app/controllers/dashboard.js index be72315deab..c4efbcff998 100644 --- a/app/controllers/dashboard.js +++ b/app/controllers/dashboard.js @@ -29,12 +29,12 @@ export default class DashboardController extends Controller { @computed('myCrates.[]') get hasMoreCrates() { - return this.get('myCrates.length') > TO_SHOW; + return this.myCrates.length > TO_SHOW; } @computed('myFollowing.[]') get hasMoreFollowing() { - return this.get('myFollowing.length') > TO_SHOW; + return this.myFollowing.length > TO_SHOW; } @task(function* () { From 954fc257270b4aae1a9734f35f547a050abe9c2f Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:46:32 +0200 Subject: [PATCH 04/11] crate.owners: Remove unnecessary `this.get()` calls --- app/controllers/crate/owners.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/crate/owners.js b/app/controllers/crate/owners.js index 4ad621728d1..887d30dfdc6 100644 --- a/app/controllers/crate/owners.js +++ b/app/controllers/crate/owners.js @@ -42,11 +42,11 @@ export default class CrateOwnersController extends Controller { switch (owner.kind) { case 'user': this.set('removed', `User ${owner.get('login')} removed as crate owner`); - this.get('crate.owner_user').removeObject(owner); + this.crate.owner_user.removeObject(owner); break; case 'team': this.set('removed', `Team ${owner.get('display_name')} removed as crate owner`); - this.get('crate.owner_team').removeObject(owner); + this.crate.owner_team.removeObject(owner); break; } } catch (error) { From 4700dce48a46c77c42ffd7b13a2dc2c7e60415b0 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:45:34 +0200 Subject: [PATCH 05/11] crate.version: Remove unnecessary `this.get()` calls --- app/controllers/crate/version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/crate/version.js b/app/controllers/crate/version.js index 2cf2fbf1e66..e5ae64b0b76 100644 --- a/app/controllers/crate/version.js +++ b/app/controllers/crate/version.js @@ -28,7 +28,7 @@ export default class CrateVersionController extends Controller { @computed('crate.owner_user', 'session.currentUser.id') get isOwner() { - return this.get('crate.owner_user').findBy('id', this.get('session.currentUser.id')); + return this.crate.owner_user.findBy('id', this.session.currentUser?.id); } @readOnly('crate.versions') sortedVersions; From 99d75b363ef4109d5002c476126c93d23a2a7544 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:45:43 +0200 Subject: [PATCH 06/11] crate.versions: Remove unnecessary `this.get()` calls --- app/controllers/crate/versions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/crate/versions.js b/app/controllers/crate/versions.js index 48c56c484dd..fc43b600fb2 100644 --- a/app/controllers/crate/versions.js +++ b/app/controllers/crate/versions.js @@ -7,6 +7,6 @@ export default class CrateVersionsController extends Controller { @computed('model.owner_user', 'session.currentUser.id') get isOwner() { - return this.get('model.owner_user').findBy('id', this.get('session.currentUser.id')); + return this.model.owner_user.findBy('id', this.session.currentUser?.id); } } From 92a15d4aa738832a2a682e078215d33ae9dd2b3d Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:34:11 +0200 Subject: [PATCH 07/11] index: Remove unnecessary `this.get()` calls --- app/controllers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/index.js b/app/controllers/index.js index db97d3dd5e0..a2b90a8164b 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -12,7 +12,7 @@ export default class IndexController extends Controller { @computed('dataTask.{lastSuccessful,isRunning}') get hasData() { - return this.get('dataTask.lastSuccessful') && !this.get('dataTask.isRunning'); + return this.dataTask.lastSuccessful && !this.dataTask.isRunning; } @(task(function* () { From c32bb1ab3c391381176d28e5fd6933803d132b9d Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:32:50 +0200 Subject: [PATCH 08/11] me.crates: Remove unnecessary `this.get()` calls --- app/routes/me/crates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/me/crates.js b/app/routes/me/crates.js index 9a10cd5fc3b..7ea1c590137 100644 --- a/app/routes/me/crates.js +++ b/app/routes/me/crates.js @@ -7,7 +7,7 @@ export default class MeCratesRoute extends AuthenticatedRoute { }; model(params) { - params.user_id = this.get('session.currentUser.id'); + params.user_id = this.session.currentUser.id; return this.store.query('crate', params); } } From 1b2b9ed84bcfe72e6092e9b20143bbf64acac3ad Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:35:05 +0200 Subject: [PATCH 09/11] me.index: Remove unnecessary `this.get()` calls --- app/controllers/me/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/me/index.js b/app/controllers/me/index.js index f1bea45b157..74675595a72 100644 --- a/app/controllers/me/index.js +++ b/app/controllers/me/index.js @@ -28,7 +28,7 @@ export default class MeIndexController extends Controller { } setAllEmailNotifications(value) { - this.get('ownedCrates').forEach(c => { + this.ownedCrates.forEach(c => { c.set('email_notifications', value); }); } @@ -41,7 +41,7 @@ export default class MeIndexController extends Controller { await ajax(`/api/v1/me/email_notifications`, { method: 'PUT', body: JSON.stringify( - this.get('ownedCrates').map(c => ({ + this.ownedCrates.map(c => ({ id: parseInt(c.id, 10), email_notifications: c.email_notifications, })), From 344309f9f8f107b3213eeec3c4d8fad4f4bc5432 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:33:59 +0200 Subject: [PATCH 10/11] search: Remove unnecessary `this.get()` calls --- app/controllers/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/search.js b/app/controllers/search.js index cfd5fe3c244..9cc73fb4920 100644 --- a/app/controllers/search.js +++ b/app/controllers/search.js @@ -16,12 +16,12 @@ export default class SearchController extends Controller { @computed('dataTask.{lastSuccessful,isRunning}') get hasData() { - return this.get('dataTask.lastSuccessful') || !this.get('dataTask.isRunning'); + return this.dataTask.lastSuccessful || !this.dataTask.isRunning; } @computed('dataTask.{lastSuccessful,isRunning}') get firstResultPending() { - return !this.get('dataTask.lastSuccessful') && this.get('dataTask.isRunning'); + return !this.dataTask.lastSuccessful && this.dataTask.isRunning; } @readOnly('model.meta.total') totalItems; From 21d2bc39edfb025779715d3782ca070f826c6ba4 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 18 Oct 2020 12:33:01 +0200 Subject: [PATCH 11/11] ESLint: Enable `ember/no-get` rule --- .eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 25d75ae4de8..f9b48a7e40b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,7 +21,6 @@ module.exports = { 'ember/no-classic-classes': 'error', 'ember/no-empty-attrs': 'off', - 'ember/no-get': 'off', 'ember/require-computed-property-dependencies': 'off', 'import-helpers/order-imports': [