KyperTech/matter

View on GitHub

Showing 41 of 41 total issues

File index.js has 463 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import config from './config'
import logger from './utils/logger'
import * as dom from './utils/dom'
import * as request from './utils/request'
import * as ProviderAuth from './utils/providerAuth'
Severity: Minor
Found in src/index.js - About 7 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export function put (endpoint, data) {
      const imageData = (data && data.files) ? handleFiles(data) : null
      let req = superagent.put(endpoint)
      req = addAuthHeader(req)
      req.send(imageData || data)
    Severity: Major
    Found in src/utils/request.js and 1 other location - About 2 hrs to fix
    src/utils/request.js on lines 14..20

    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 86.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export function post (endpoint, data) {
      const imageData = (data && data.files) ? handleFiles(data) : null
      let req = superagent.post(endpoint)
      req = addAuthHeader(req)
      req.send(imageData || data)
    Severity: Major
    Found in src/utils/request.js and 1 other location - About 2 hrs to fix
    src/utils/request.js on lines 22..28

    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 86.

    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

    Further Reading

    Function login has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      login (loginData) {
        if (!loginData || (!isObject(loginData) && !isString(loginData))) {
          logger.error({
            description: 'Username/Email and Password are required to login',
            func: 'login', obj: 'Matter'
    Severity: Major
    Found in src/index.js - About 2 hrs to fix

      Function signup has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        signup (signupData) {
          logger.debug({
            description: 'Signup called.', signupData,
            func: 'signup', obj: 'Matter'
          })
      Severity: Major
      Found in src/index.js - About 2 hrs to fix

        Function isInGroups has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          isInGroups (checkGroups) {
            if (!this.isLoggedIn) {
              logger.log({
                description: 'No logged in user to check.',
                func: 'isInGroups', obj: 'Matter'
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

          Function isInGroup has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            isInGroup (checkGroups) {
              if (!this.isLoggedIn) {
                logger.error({
                  description: 'No logged in user to check for groups.',
                  func: 'isInGroup', obj: 'Matter'
          Severity: Minor
          Found in src/index.js - About 1 hr to fix

            Function getCurrentUser has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getCurrentUser () {
                if (this.currentUser) {
                  logger.debug({
                    description: 'Current is already available. Returning user.',
                    func: 'currentUser', obj: 'Matter'
            Severity: Minor
            Found in src/index.js - About 1 hr to fix

              Function updateAccount has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                updateAccount (updateData) {
                  if (!this.isLoggedIn) {
                    logger.error({
                      description: 'No current user profile to update.',
                      func: 'updateAccount', obj: 'Matter'
              Severity: Minor
              Found in src/index.js - About 1 hr to fix

                Function handleResponse has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function handleResponse (req) {
                  return new Promise((resolve, reject) => {
                    if (typeof req.end !== 'function') {
                      logger.warn({
                        description: 'req.end is not a function', func: 'handleResponse'
                Severity: Minor
                Found in src/utils/request.js - About 1 hr to fix

                  Function authWithServer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function authWithServer (provider) {
                    initializeOAuth()
                    return get(`${config.serverUrl}/stateToken`).then(params => {
                      return new Promise((resolve, reject) => {
                        window.OAuth.popup(provider, { state: params.token }).done(result => {
                  Severity: Minor
                  Found in src/utils/providerAuth.js - About 1 hr to fix

                    Function getItem has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function getItem (itemName) {
                      if (data[itemName]) {
                        return data[itemName]
                      } else if (localExists()) {
                        let itemStr = window.sessionStorage.getItem(itemName)
                    Severity: Minor
                    Found in src/utils/envStorage.js - About 1 hr 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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        if (!file) {
                          logger.error({
                            description: 'File is required to upload Avatar.',
                            func: 'uploadAvatar', obj: 'Matter'
                          })
                    Severity: Major
                    Found in src/index.js and 1 other location - About 1 hr to fix
                    src/index.js on lines 150..159

                    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 58.

                    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

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        if (!signupData) {
                          logger.error({
                            description: 'Signup information is required to signup.',
                            func: 'signup', obj: 'Matter'
                          })
                    Severity: Major
                    Found in src/index.js and 1 other location - About 1 hr to fix
                    src/index.js on lines 489..498

                    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 58.

                    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

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        if (!this.isLoggedIn) {
                          logger.error({
                            description: 'No current user profile to update.',
                            func: 'updateAccount', obj: 'Matter'
                          })
                    Severity: Major
                    Found in src/index.js and 1 other location - About 1 hr to fix
                    src/index.js on lines 480..488

                    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 57.

                    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

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                        if (!this.isLoggedIn) {
                          logger.error({
                            description: 'Must be logged in to upload an image.',
                            func: 'uploadAvatar', obj: 'Matter'
                          })
                    Severity: Major
                    Found in src/index.js and 1 other location - About 1 hr to fix
                    src/index.js on lines 430..438

                    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 57.

                    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

                    Further Reading

                    Function buildMessageArgs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function buildMessageArgs (logData) {
                      let msgStr = ''
                      let msgObj = {}
                      // TODO: Attach time stamp
                      // Attach location information to the beginning of message
                    Severity: Minor
                    Found in src/utils/logger.js - About 1 hr to fix

                      Function logout has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        logout () {
                          // TODO: Handle logging out of providers
                          if (!this.isLoggedIn) {
                            logger.warn({
                              description: 'No logged in account to log out.',
                      Severity: Minor
                      Found in src/index.js - About 1 hr to fix

                        Function authUsingProvider has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          authUsingProvider (provider) {
                            if (!provider) {
                              logger.info({
                                description: 'Provider required to sign up.',
                                func: 'authUsingProvider', obj: 'Matter'
                        Severity: Minor
                        Found in src/index.js - About 1 hr to fix

                          Function getCookie has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export function getCookie (cookieName) {
                            if (typeof window === 'undefined' || typeof document === 'undefined') {
                              return ''
                            }
                            let name = cookieName + '='
                          Severity: Minor
                          Found in src/utils/cookies.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

                          Severity
                          Category
                          Status
                          Source
                          Language