Showing 89 of 875 total issues
Function setHeadTags
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setHeadTags(model) {
return [{
type: 'meta',
tagId: 'meta-description',
attrs: {
Function _getSortingKey
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_getSortingKey(sort) {
const controller = this.controllerFor(get(this, 'routeName'));
const mediaType = get(controller, 'media');
let sortKey;
Function createPost
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
createPost: task(function* (content, options) {
const data = { content, user: get(this, 'session.account'), ...options };
// posting on another user's profile
if (get(this, 'user') !== undefined && get(this, 'user.id') !== get(this, 'session.account.id')) {
set(data, 'targetUser', get(this, 'user'));
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _handleRealtime
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_handleRealtime(object) {
// handle deletion
(get(object, 'deleted') || []).forEach(activityId => {
let activity = get(this, 'feed').findBy('id', activityId);
if (activity) {
Function init
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
init() {
this._super(...arguments);
set(this, 'replies', []);
set(this, 'galleryItems', []);
if (get(this, 'isTopLevel') === true && get(this, 'comment.repliesCount') > 0) {
Function thumbSize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
const thumbSize = (length, orientation, index) => {
const max = 538;
const margin = 4;
if (orientation === 'square') {
const box = (max - 4) / 2;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function buildMessageTask
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
buildMessageTask: task(function* () {
const targetType = get(this, 'item.target.modelType');
const verb = get(this, 'item.verb');
switch (targetType) {
// ban, invite, permission
Function initPlayer
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
initPlayer() {
const containerId = get(this, 'elementId');
// Initialize the HuluPlayer instance
const options = {
Function _schemaData
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_schemaData() {
const data = {
'@context': 'http://schema.org',
'@type': 'BreadcrumbList',
itemListElement: [{
Function _buildOptions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_buildOptions(type) {
const options = {
page: { limit: 20 },
filter: {}
};
Function setHeadTags
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setHeadTags(model) {
const description = `${get(this, 'intl').t('head.users.description', { user: get(model, 'name') })} ${get(model, 'about')}`;
return [{
type: 'meta',
tagId: 'meta-description',
Function _handleRealtime
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_handleRealtime(object) {
// new activities
if (isPresent(get(object, 'new'))) {
get(this, 'getNotifications').perform(get(object, 'new.length')).then(groups => {
// remove duplicate records
Function _getRequestOptions
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_getRequestOptions(params) {
const options = {
filter: {},
page: { offset: 0, limit: 20 },
fields: this._getFieldsets()
Function activate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
activate() {
this._super(...arguments);
this._handleScroll = () => { this.handleScroll(); };
document.body.classList.add('cover-page');
Function _getRequestOptions
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_getRequestOptions({ media, status, sort, title }) {
const user = this.modelFor('users');
const options = {
include: `${media},user,mediaReaction`,
filter: {
Function groupByTimeAll
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
groupByTimeAll: computed('group.activities.@each.isDeleted', function() {
const temp = {};
const activities = get(this, 'group.activities').toArray().sort((a, b) => {
if (get(a, 'time').isBefore(get(b, 'time'))) {
return 1;
Function resetPassword
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
resetPassword: task(function* () {
// get the current user based off the token supplied as a query param
let user = yield get(this, 'ajax').request('/users?filter[self]=true', {
headers: {
Authorization: `Bearer ${get(this, 'usableToken')}`
Function uploadImagesTask
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
uploadImagesTask: task(function* (file) {
const { access_token: accessToken } = get(this, 'session.data.authenticated');
const headers = {
accept: 'application/vnd.api+json',
authorization: `Bearer ${accessToken}`
Function createAccount
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createAccount: task(function* () {
const user = get(this, 'user');
yield user.save()
.then(() => {
const { email: identification, password } = getProperties(user, 'email', 'password');
Function beforeModel
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
beforeModel({ queryParams }) {
const { token } = queryParams;
return new RSVP.Promise((resolve, reject) => {
get(this, 'ajax').request('/users?filter[self]=true', {
headers: { Authorization: `Bearer ${token}` }