File iframe-saver.ts
has 533 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { ParentEndpoint } from "iframe-phone";
import * as DOMPurify from "dompurify";
import { IframePhoneManager } from "./iframe-phone-manager";
import { IFrameSaverPluginApi } from "./iframe-saver-plugin";
import { ModalApiPlugin } from "./modal-api-plugin";
Function phoneAnswered
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
private phoneAnswered() {
// Workaround IframePhone problem - phone_answered callback can be triggered multiple times:
// https://www.pivotaltracker.com/story/show/89602814
if (this.alreadySetup) {
return;
Function initInteractive
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private initInteractive(err: string | null = null, response: IInteractiveRunStateResponse | null = null) {
const globalInteractiveState = (typeof globalIframeSaver !== "undefined" && globalIframeSaver !== null)
? globalIframeSaver.globalState
: null;
const initInteractiveMsg: IInitInteractive = {
Function interactiveStateProps
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const interactiveStateProps = (data: IInteractiveRunStateResponse | null): IInteractiveStateProps => ({
interactiveState: (data != null ? safeJSONParse(data.raw_data) : undefined),
hasLinkedInteractive: (data != null ? data.has_linked_interactive : undefined),
linkedState: (data != null ? safeJSONParse(data.linked_state) : undefined),
// tslint:disable-next-line:max-line-length
- 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 constructor
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor($iframe: JQuery, $dataDiv: JQuery, $deleteButton: JQuery) {
this.$iframe = $iframe;
this.$deleteButton = $deleteButton;
this.enableLearnerState = $dataDiv.data("enable-learner-state");
this.interactiveRunStateUrl = $dataDiv.data("interactive-run-state-url"); // get and put our data here.
Function saveLearnerState
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public saveLearnerState(interactiveJson: string | object | null) {
if (!this.learnerStateSavingEnabled()) { return; }
const runSuccess = () => {
this.savedState = interactiveJson;
Function loadInteractive
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private loadInteractive(callback: () => void) {
if (!this.learnerStateSavingEnabled()) {
this.initInteractive();
callback();
return;
Function initializeAttachmentsManager
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private async initializeAttachmentsManager() {
if (!IFrameSaver.isAttachmentsManagerInitialized) {
// Try to initialize manager only once.
IFrameSaver.isAttachmentsManagerInitialized = true;
try {
- 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 saveLearnerState
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public saveLearnerState(interactiveJson: string | object | null) {
if (!this.learnerStateSavingEnabled()) { return; }
const runSuccess = () => {
this.savedState = interactiveJson;
- 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 loadInteractive
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private loadInteractive(callback: () => void) {
if (!this.learnerStateSavingEnabled()) {
this.initInteractive();
callback();
return;
- 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"