valasek/timesheet

View on GitHub

Showing 11 of 66 total issues

Function exports has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (ctx) {
  return {
    // app boot file (/src/boot)
    // --> boot files are part of "main.js"
    // https://quasar.dev/quasar-cli/cli-documentation/boot-files
Severity: Major
Found in client/quasar.conf.js - About 3 hrs to fix

    Method API.Upload has 74 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (api *API) Upload(c *gin.Context) {
    
        // parse and validate file and post parameters
        form, err := c.MultipartForm()
        if err != nil {
    Severity: Minor
    Found in server/api/api.go - About 1 hr to fix

      Method API.Upload has 11 return statements (exceeds 4 allowed).
      Open

      func (api *API) Upload(c *gin.Context) {
      
          // parse and validate file and post parameters
          form, err := c.MultipartForm()
          if err != nil {
      Severity: Major
      Found in server/api/api.go - About 1 hr to fix

        Function unzip has 8 return statements (exceeds 4 allowed).
        Open

        func unzip(src, dest string) error {
            r, err := zip.OpenReader(src)
            if err != nil {
                return err
            }
        Severity: Major
        Found in server/api/apiFunctions.go - About 50 mins to fix

          Function SeedTable has 6 return statements (exceeds 4 allowed).
          Open

          func SeedTable(api *API, table, file string) (count int) {
              switch table {
              case "rates":
                  if api.rates.RateCount() > 0 {
                      logger.Log.Warn(fmt.Sprintf("- rates, file %s skipped, table contains %d records", file, api.rates.RateCount()))
          Severity: Major
          Found in server/api/api.go - About 40 mins to fix

            Function getborderDays has 5 return statements (exceeds 4 allowed).
            Open

            func getborderDays(year, month string) (days []string, err error) {
                layout := "2006-1-02"
                monthStart, err := time.Parse(layout, year+"-"+month+"-01")
                if err != nil {
                    return nil, err
            Severity: Major
            Found in server/models/reportedRecords.go - About 35 mins to fix

              Function restoreDB has 5 return statements (exceeds 4 allowed).
              Open

              func restoreDB(f *os.File) error {
                  // delete if target folder exists
                  err := os.RemoveAll(viper.GetString("uploadFolderTemp"))
                  if err != nil {
                      return err
              Severity: Major
              Found in server/api/apiFunctions.go - About 35 mins to fix

                Method ReportedRecordManager.ReportedRecordUpdate has 5 return statements (exceeds 4 allowed).
                Open

                func (db *ReportedRecordManager) ReportedRecordUpdate(r UpdatedValue) ReportedRecord {
                    updateValue := UpdatedValue{
                        ID:    r.ID,
                        Type:  r.Type,
                        Value: r.Value,
                Severity: Major
                Found in server/models/reportedRecords.go - About 35 mins to fix

                  Function export has 5 return statements (exceeds 4 allowed).
                  Open

                  func export() (fileName string, err error) {
                      fileName = "timesheet-backup.zip"
                      db := ConnectDB()
                      defer db.Close()
                      exportFolder := viper.GetString("export.location")
                  Severity: Major
                  Found in server/api/apiFunctions.go - About 35 mins to fix

                    Function uploadedFileList has 5 return statements (exceeds 4 allowed).
                    Open

                    func uploadedFileList() (list map[string]string, err error) {
                        list = make(map[string]string)
                        files, err := ioutil.ReadDir(filepath.Clean(viper.GetString("uploadFolderTemp")))
                        if err != nil {
                            return nil, err
                    Severity: Major
                    Found in server/api/apiFunctions.go - About 35 mins to fix

                      Function SET_CONSULTANTS has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        SET_CONSULTANTS (state, consultants) {
                          state.all = consultants.sort(function (a, b) {
                            var nameA = a.name.toUpperCase()
                            var nameB = b.name.toUpperCase()
                            if (nameA < nameB) {
                      Severity: Minor
                      Found in client/src/store/modules/consultants.js - About 35 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