TUBB/h5-imageviewer

View on GitHub

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,
Severity: Minor
Found in src/imgListViewer.js - About 1 day 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

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'
Severity: Major
Found in src/imgListViewer.js - About 1 day to fix

    Function registerViewerAlloyFinger has 121 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const registerViewerAlloyFinger = () => {
      const {
        pageDampingFactor,
        imgMoveFactor,
        pageThreshold,
    Severity: Major
    Found in src/imgListViewer.js - About 4 hrs to fix

      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
      Severity: Minor
      Found in src/imgListViewer.js - About 3 hrs 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

      Function appendSingleViewer has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const appendSingleViewer = () => {
        const {
          imgObj,
          options: {
            errorPlh,
      Severity: Major
      Found in src/imgViewer.js - About 2 hrs to fix

        Function imgAlloyFinger has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const imgAlloyFinger = (el, options) => {
          const {
            pressMoveListener = noop,
            touchEndListener = noop,
            singleTapListener = noop,
        Severity: Major
        Found in src/imgAlloyFinger.js - About 2 hrs to fix

          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
          Severity: Major
          Found in src/imgListViewer.js - About 2 hrs to fix

            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) {
            Severity: Major
            Found in src/utils/transform.js - About 2 hrs to fix

              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) {
              Severity: Major
              Found in src/utils/transform.js - About 2 hrs to fix

                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,
                Severity: Minor
                Found in src/imgListViewer.js - About 1 hr to fix

                  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
                  Severity: Minor
                  Found in src/imgListViewer.js - About 1 hr to fix

                    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) {
                    Severity: Major
                    Found in src/utils/transform.js - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in src/utils/transform.js - About 1 hr to fix

                        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 ||
                        Severity: Minor
                        Found in src/imgListViewer.js - About 1 hr to fix

                          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
                          Severity: Minor
                          Found in src/imgListViewer.js - About 1 hr to fix

                            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'
                            Severity: Minor
                            Found in src/example/ExampleNode.js - About 1 hr to fix

                              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]
                              Severity: Minor
                              Found in src/utils/transform.js - About 1 hr to fix

                                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
                                Severity: Minor
                                Found in src/imgListViewer.js - About 55 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

                                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
                                Severity: Minor
                                Found in src/imgAlloyFinger.js - About 55 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

                                Function To has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                export default function To (el, property, value, time, ease, onEnd, onChange) {
                                Severity: Major
                                Found in src/utils/to.js - About 50 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language