File iframe.js
has 837 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* File: iframeResizer.js
* Desc: Force iframes to size to content.
* Requires: iframeResizer.contentWindow.js to be loaded into the target frame.
* Doc: https://github.com/davidjbradshaw/iframe-resizer
Function iFrameListener
has 318 lines of code (exceeds 25 allowed). Consider refactoring. Open
function iFrameListener(event) {
function resizeIFrame() {
function resize() {
setSize(messageData);
setPagePosition(iframeId);
Function setupIFrame
has 129 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupIFrame(iframe,options) {
function setLimits() {
function addStyle(style) {
if ((Infinity !== settings[iframeId][style]) && (0 !== settings[iframeId][style])) {
iframe.style[style] = settings[iframeId][style] + 'px';
Function factory
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function factory() {
function init(options,element) {
function chkType() {
if(!element.tagName) {
throw new TypeError('Object is not a valid DOM element');
Function fixHiddenIFrames
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fixHiddenIFrames() {
function checkIFrames() {
function checkIFrame(settingId) {
function chkDimension(dimension) {
return '0px' === (settings[settingId] && settings[settingId].iframe.style[dimension]);
Function actionMsg
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function actionMsg() {
if(settings[iframeId] && settings[iframeId].firstRun) firstRun();
switch(messageData.type) {
Function isMessageFromIFrame
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function isMessageFromIFrame() {
function checkAllowedOrigin() {
function checkList() {
var
i = 0,
Function trigger
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function trigger(calleeMsg, msg, iframe, id, noResponseWarning) {
function postMessageToIFrame() {
var target = settings[id] && settings[id].targetOrigin;
log(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target);
iframe.contentWindow.postMessage( msgId + msg, target );
Function findTarget
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findTarget(location) {
function jumpToTarget() {
var jumpPosition = getElementPosition(target);
log(iframeId,'Moving to in page link (#'+hash+') at x: '+jumpPosition.x+' y: '+jumpPosition.y);
Function scrollRequestFromChild
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function scrollRequestFromChild(addOffset) {
/* istanbul ignore next */ //Not testable in Karma
function reposition() {
pagePosition = newPosition;
scrollTo();
Function trigger
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function trigger(calleeMsg, msg, iframe, id, noResponseWarning) {
Similar blocks of code found in 4 locations. Consider refactoring. Open
function addEventListener(obj,evt,func) {
/* istanbul ignore else */ // Not testable in PhantonJS
if ('addEventListener' in window) {
obj.addEventListener(evt,func, false);
} else if ('attachEvent' in window) {//IE
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 68.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
function removeEventListener(el,evt,func) {
/* istanbul ignore else */ // Not testable in phantonJS
if ('removeEventListener' in window) {
el.removeEventListener(evt,func, false);
} else if ('detachEvent' in window) { //IE
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 68.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
pagePosition = {
x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,
y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop
};
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 64.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76