Showing 28 of 45 total issues
Function registerViewerAlloyFinger
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
const registerViewerAlloyFinger = () => {
const {
pageDampingFactor,
imgMoveFactor,
pageThreshold,
- 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
File imgListViewer.js
has 514 lines of code (exceeds 250 allowed). Consider refactoring. Open
import './main.less'
import imageLoaded from './utils/image_loaded'
import Transform from './utils/transform'
import To from './utils/to'
import ease from './utils/ease'
Function registerViewerAlloyFinger
has 121 lines of code (exceeds 25 allowed). Consider refactoring. Open
const registerViewerAlloyFinger = () => {
const {
pageDampingFactor,
imgMoveFactor,
pageThreshold,
Function setCurrentPage
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
export const setCurrentPage = pageIndex => {
if (viewerData === null
|| pageIndex < 0
|| pageIndex > viewerData.imgList.length - 1) {
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"
Further reading
Function appendSingleViewer
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
const appendSingleViewer = () => {
const {
imgObj,
options: {
errorPlh,
Function imgAlloyFinger
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
const imgAlloyFinger = (el, options) => {
const {
pressMoveListener = noop,
touchEndListener = noop,
singleTapListener = noop,
Function setCurrentPage
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const setCurrentPage = pageIndex => {
if (viewerData === null
|| pageIndex < 0
|| pageIndex > viewerData.imgList.length - 1) {
return
Function Matrix3D
has 16 arguments (exceeds 4 allowed). Consider refactoring. Open
var Matrix3D = function (n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
Function set
has 16 arguments (exceeds 4 allowed). Consider refactoring. Open
set: function (n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
Function initParams
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
const initParams = (imgList, options, screenRotation, cachedCurrPage) => {
let wrapOptions = {}
if (options) wrapOptions = { ...options }
const {
defaultPageIndex = 0,
Function pressMoveListener
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
pressMoveListener: evt => {
const currImgDom = getCurrImgDom()
if (!evt || !currImgDom) return
const currPageTranslateStart = currPage * window.innerWidth
const { scaleX, width, translateX } = currImgDom
Function appendTransform
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
appendTransform: function (x, y, z, scaleX, scaleY, scaleZ, rotateX, rotateY, rotateZ, skewX, skewY, originX, originY, originZ) {
Function appendTransform
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
appendTransform: function (x, y, z, scaleX, scaleY, scaleZ, rotateX, rotateY, rotateZ, skewX, skewY, originX, originY, originZ) {
var rx = rotateX * Matrix3D.DEG_TO_RAD
var cosx = this._rounded(Math.cos(rx))
var sinx = this._rounded(Math.sin(rx))
var ry = rotateY * Matrix3D.DEG_TO_RAD
Function replaceImgDom
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const replaceImgDom = (prevPage) => {
if (viewerData === null) return
const { imgList, options: { limit } } = viewerData
const lastIndex = imgList.length - 1
if (currPage === 0 ||
Function handleImgDoms
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleImgDoms = () => {
let docfrag = document.createDocumentFragment()
const { imgList } = viewerData
const lastIndex = imgList.length - 1
const { limit } = viewerData.options
Function onShowImgsClickWithDoms
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
onShowImgsClickWithDoms () {
const el = document.createElement('img')
el.src = img_close
el.alt = '地方'
el.className = 'btnClose'
Function multiplyMatrices
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
multiplyMatrices: function (a, be) {
var ae = a.elements
var te = this.elements
var a11 = ae[0]; var a12 = ae[4]; var a13 = ae[8]; var a14 = ae[12]
var a21 = ae[1]; var a22 = ae[5]; var a23 = ae[9]; var a24 = ae[13]
Function scrollToPage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const scrollToPage = (dom, targetPage, prevPage) => {
// page changed, so we reset current page's translateX、scaleX、scaleY
if (targetPage !== prevPage) {
viewerData.options.onPageChanged(targetPage)
const { translateX, translateY, scaleX, scaleY } = dom
- 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 triggerRotateEnd
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function triggerRotateEnd (dom) {
if (!dom) return
let rotation = dom.rotateZ % 360
if (rotation < 0) rotation = 360 + rotation
dom.rotateZ = rotation
- 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 To
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
export default function To (el, property, value, time, ease, onEnd, onChange) {