nypublicradio/ember-hifi

View on GitHub
addon/hifi-connections/native-audio.js

Summary

Maintainability
C
7 hrs
Test Coverage
B
82%

Sound has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

let Sound = BaseSound.extend({
  setup() {
    let audio = this.requestControl();

    audio.src = this.get('url');
Severity: Minor
Found in addon/hifi-connections/native-audio.js - About 3 hrs to fix

    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';
    Severity: Minor
    Found in addon/hifi-connections/native-audio.js - About 2 hrs to fix

      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
      Severity: Minor
      Found in addon/hifi-connections/native-audio.js - About 1 hr to fix

        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) {
        Severity: Minor
        Found in addon/hifi-connections/native-audio.js - About 35 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status