Codeminer42/Punchclock

View on GitHub

Showing 38 of 38 total issues

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

            <div className="col">
              <div className="d-flex align-items-center">
                <i style={{color: isSelectedsEmpty ? "#9ea8ad" : "#555"}} className="fa fa-utensils fa-lg"></i>
                <input
                  disabled={isSelectedsEmpty}
Severity: Major
Found in app/javascript/packs/components/Form.js and 1 other location - About 1 day to fix
app/javascript/packs/components/Form.js on lines 68..91

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

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

            <div className="col">
              <div className="d-flex align-items-center">
                <i style={{color: isSelectedsEmpty ? "#9ea8ad" : "#555"}} className="fa fa-coffee fa-lg"></i>
                <input
                  disabled={isSelectedsEmpty}
Severity: Major
Found in app/javascript/packs/components/Form.js and 1 other location - About 1 day to fix
app/javascript/packs/components/Form.js on lines 92..115

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

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

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

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

          export const onPrev = (dispatch) => (base) => {
            dispatch({
              type: PREV,
              payload: redefine(Calendar.prev(base)),
            });
          Severity: Major
          Found in app/javascript/packs/reducers/calendarReducer.js and 1 other location - About 2 hrs to fix
          app/javascript/packs/reducers/calendarReducer.js on lines 234..240

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

          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 const onNext = (dispatch) => (base) => {
            dispatch({
              type: NEXT,
              payload: redefine(Calendar.next(base)),
            });
          Severity: Major
          Found in app/javascript/packs/reducers/calendarReducer.js and 1 other location - About 2 hrs to fix
          app/javascript/packs/reducers/calendarReducer.js on lines 226..232

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

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

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

                case PREV:
                  return {
                    ...state,
                    base: action.payload.base,
                    start: action.payload.start,
            Severity: Major
            Found in app/javascript/packs/reducers/calendarReducer.js and 3 other locations - About 2 hrs to fix
            app/javascript/packs/reducers/calendarReducer.js on lines 56..64
            app/javascript/packs/reducers/calendarReducer.js on lines 74..82
            app/javascript/packs/reducers/calendarReducer.js on lines 91..99

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

            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 4 locations. Consider refactoring.
            Open

                case NEXT:
                  return {
                    ...state,
                    base: action.payload.base,
                    start: action.payload.start,
            Severity: Major
            Found in app/javascript/packs/reducers/calendarReducer.js and 3 other locations - About 2 hrs to fix
            app/javascript/packs/reducers/calendarReducer.js on lines 56..64
            app/javascript/packs/reducers/calendarReducer.js on lines 65..73
            app/javascript/packs/reducers/calendarReducer.js on lines 91..99

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

            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 4 locations. Consider refactoring.
            Open

                case INITIALIZE:
                  return {
                    ...state,
                    base: action.payload.base,
                    start: action.payload.start,
            Severity: Major
            Found in app/javascript/packs/reducers/calendarReducer.js and 3 other locations - About 2 hrs to fix
            app/javascript/packs/reducers/calendarReducer.js on lines 65..73
            app/javascript/packs/reducers/calendarReducer.js on lines 74..82
            app/javascript/packs/reducers/calendarReducer.js on lines 91..99

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

            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 4 locations. Consider refactoring.
            Open

                case ERASE:
                  return {
                    ...state,
                    selecteds: action.sheetsPayload.selecteds,
                    sheetsSaveds: action.sheetsPayload.sheetsSaveds,
            Severity: Major
            Found in app/javascript/packs/reducers/calendarReducer.js and 3 other locations - About 2 hrs to fix
            app/javascript/packs/reducers/calendarReducer.js on lines 56..64
            app/javascript/packs/reducers/calendarReducer.js on lines 65..73
            app/javascript/packs/reducers/calendarReducer.js on lines 74..82

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

            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

                case SET_TIME_SHEET:
                  return {
                    ...state,
                    selecteds: action.sheetsPayload.selecteds,
                    sheets: action.sheetsPayload.sheets,
            Severity: Major
            Found in app/javascript/packs/reducers/calendarReducer.js and 1 other location - About 1 hr to fix
            app/javascript/packs/reducers/calendarReducer.js on lines 142..149

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

            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

                case SAVE_SHEET_SUCCESS:
                  return {
                    ...state,
                    sheetsSaveds: action.sheetsPayload.sheetsSaveds,
                    sheets: action.sheetsPayload.sheets,
            Severity: Major
            Found in app/javascript/packs/reducers/calendarReducer.js and 1 other location - About 1 hr to fix
            app/javascript/packs/reducers/calendarReducer.js on lines 83..90

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

            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

                    { from: this.refs.from1.value,
                      to: this.refs.to1.value,
                      project_id: this.refs.project.el.val()},
            Severity: Major
            Found in app/javascript/packs/components/Form.js and 1 other location - About 1 hr to fix
            app/javascript/packs/components/Form.js on lines 155..157

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

            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

                    { from: this.refs.from2.value,
                      to: this.refs.to2.value,
                      project_id: this.refs.project.el.val()}
            Severity: Major
            Found in app/javascript/packs/components/Form.js and 1 other location - About 1 hr to fix
            app/javascript/packs/components/Form.js on lines 152..154

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

            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

            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

            Severity
            Category
            Status
            Source
            Language