Showing 16 of 20 total issues
File hifi.js
has 424 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { or, readOnly, equal, reads, alias } from '@ember/object/computed';
import { later, cancel } from '@ember/runloop';
import { isEmpty } from '@ember/utils';
import { assign } from '@ember/polyfills';
import { getOwner } from '@ember/application';
`` has 36 functions (exceeds 20 allowed). Consider refactoring. Open
export default Service.extend(Evented, DebugLogging, {
debugName: 'ember-hifi',
poll: service(),
soundCache: service('hifi-cache'),
isMobileDevice: computed({
Sound
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
let Sound = BaseSound.extend({
setup() {
let audio = this.requestControl();
audio.src = this.get('url');
Function load
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
load(urlsOrPromise, options) {
let sharedAudioAccess = this._createAndUnlockAudio();
options = assign({
debugName: `load-${Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 3)}`,
File native-audio.js
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { A } from '@ember/array';
import { run } from '@ember/runloop';
import Mixin from '@ember/object/mixin';
import BaseSound from './base';
import Ember from 'ember';
Function init
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
init: function() {
let {
audioLoading,
audioLoaded,
audioReady,
Function load
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
load(urlsOrPromise, options) {
let sharedAudioAccess = this._createAndUnlockAudio();
options = assign({
debugName: `load-${Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 3)}`,
- 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 getInfoFromUrl
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
getInfoFromUrl: function() {
if (!this.get('url')) {
return {};
}
else if (this.get('url').startsWith('/')) {
- 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 promise
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
let promise = new RSVP.Promise((resolve, reject) => {
return this._resolveUrls(urlsOrPromise).then(urlsToTry => {
if (isEmpty(urlsToTry)) {
return reject(new Error('[ember-hifi] URLs must be provided'));
}
Function _handleAudioEvent
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handleAudioEvent(eventName, e) {
if (!this.urlsAreEqual(e.target.src, this.get('url')) && e.target.src !== '') {
// This event is not for us if our srcs aren't equal
// but if the target src is empty it means we've been stopped and in
Function setup
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup() {
let urls = makeArray(this.get('url'));
let sound = this;
let options = Object.assign({
src: urls,
Function _setupHLSEvents
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_setupHLSEvents(hls) {
hls.on(HLS.Events.MEDIA_ATTACHED, () => {
this.debug('media attached');
hls.loadSource(this.get('url'));
Function requestControl
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
requestControl(who) {
let owner = this.get('owner');
if ((owner !== who) && owner) {
who.debug("I need audio control");
- 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 restoreState
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
restoreState() {
let sharedElement = this.audioElement();
let internalElement = this.get('_audioElement');
if (this.get('sharedAudioAccess') && internalElement) {
- 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 canPlay
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
canPlay(url) {
let usablePlatform = this.canUseConnection(url);
if (!usablePlatform) {
return false;
}
- 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 log
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
log(content) {
if (window.console && window.console.log) {
const colorString = `color: ${this.color}; font-weight: bold;`;
const name = this.name.slice(0, this.padLength);
const titleContent = Array(this.padLength + 3 - name.length).join(' ');
- 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"