Codeminer42/Punchclock

View on GitHub

Showing 14 of 38 total issues

File calendarReducer.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Moment from 'moment';
import Immutable from 'immutable';
import * as Calendar from '../utils/calendar';
import { push } from 'react-router-redux';
import { fetchSheets, fetchHolidays, saveSheets, fetchCurrentAllocation } from '../api';
Severity: Minor
Found in app/javascript/packs/reducers/calendarReducer.js - About 4 hrs to fix

    Function render has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const { calendar: { selecteds } } = this.props;
        const workPeriods = this.state.workPeriods;
    
        const isSelectedsEmpty = selecteds.isEmpty();
    Severity: Major
    Found in app/javascript/packs/components/Form.js - About 3 hrs to fix

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

      module.exports = function(api) {
        var validEnv = ['development', 'test', 'production']
        var currentEnv = api.env()
        var isDevelopmentEnv = api.env('development')
        var isProductionEnv = api.env('production')
      Severity: Major
      Found in babel.config.js - About 3 hrs to fix

        File user.rb has 300 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        ActiveAdmin.register User do
          decorate_with UserDecorator
        
          includes :mentor
        
        
        Severity: Minor
        Found in app/admin/user.rb - About 3 hrs to fix

          Function render has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            render(){
              const {
                onPrev,
                onNext,
                onSelectWeek,
          Severity: Major
          Found in app/javascript/packs/components/Calendar.js - About 2 hrs to fix

            Method call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def call
                error_message = I18n.t('activerecord.errors.models.period.attributes.base.invalid_periods')
            
                return Result.new(false, [error_message]) if !@additions.empty? && invalid_day_periods?
            
            
            Severity: Minor
            Found in app/services/create_punches_in_batch_service.rb - 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

            Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def initialize(user)
                return if user.nil?
            
                can :manage, Punch, user_id: user.id
                can :read, User, id: user.id
            Severity: Minor
            Found in app/models/ability.rb - 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

            Method by_created_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def by_created_date(query)
                return query unless created_at_start.present? || created_at_end.present?
            
                if created_at_start && created_at_end
                  query.where(evaluations: { created_at: created_at_start..created_at_end })
            Severity: Minor
            Found in app/queries/evaluation_query.rb - 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

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

            export const onToggle = (dispatch) => (day, selecteds) => {
              return dispatch((dispatch, getState) => {
                let newSelecteds = selecteds;
                if(isSelected(selecteds, day)) {
                  newSelecteds = newSelecteds.delete(day);
            Severity: Minor
            Found in app/javascript/packs/reducers/calendarReducer.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

            Method authenticate_otp has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def authenticate_otp
                VerifyUserAuthenticity.call(**verify_user_authenticity_params) do |result|
                  @user = result.user
            
                  return unless result.otp_required_for_login?
            Severity: Minor
            Found in app/controllers/concerns/two_factor_authentication.rb - 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

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

            const Day = ({ day, selecteds, holidays, inner, onToggle, today, selected, sheet }) => {
              let holiday = () => isHoliday(selecteds, day, holidays)
              let overtime = () => overtimeAllowed()
            
              let handleToggle = () => {
            Severity: Minor
            Found in app/javascript/packs/components/Day.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

            Method by_evaluation_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def by_evaluation_date(query)
                return query unless evaluation_date_start.present? || evaluation_date_end.present?
            
                if evaluation_date_start && evaluation_date_end
                  query.where(evaluations: { evaluation_date: evaluation_date_start..evaluation_date_end })
            Severity: Minor
            Found in app/queries/evaluation_query.rb - 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

            Method date_format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def date_format
                FIELDS_TO_BE_VALIDATED.each do |field|
                  next if self[field].blank?
            
                  errors.add(field, 'Invalid date') unless valid_date?(self[field])
            Severity: Minor
            Found in app/models/professional_experience.rb - About 25 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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(api) {
              var validEnv = ['development', 'test', 'production']
              var currentEnv = api.env()
              var isDevelopmentEnv = api.env('development')
              var isProductionEnv = api.env('production')
            Severity: Minor
            Found in babel.config.js - About 25 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