WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

export const getStore = () => {
  const reactRoot = document.getElementById('react_root');
  const navRoot = document.getElementById('nav_root');

  if (!reactRoot && !navRoot) {
Severity: Minor
Found in app/assets/javascripts/components/util/create_store.js - About 1 hr to fix

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

    export default function alerts(state = initialState, action) {
      switch (action.type) {
        case RECEIVE_ALERTS: {
          const newState = { ...state };
          const sortedAlerts = sortByKey(action.data.alerts, 'created_at', null, SORT_DESCENDING.created_at);
    Severity: Minor
    Found in app/assets/javascripts/reducers/alerts.js - About 1 hr to fix

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

      const reducer = (state = initialState, action) => {
        switch (action.type) {
          case ALERT_INSTRUCTOR_UPDATE_MESSAGE:
            return {
              ...state,
      Severity: Minor
      Found in app/assets/javascripts/reducers/instructor_alert.js - About 1 hr to fix

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

          const renderWeekday = (weekday) => {
            let dayClassName = 'DayPicker-Weekday';
            let customModifiers = [];
        
            if (modifiers) {
        Severity: Minor
        Found in app/assets/javascripts/components/common/weekday_picker.jsx - About 1 hr to fix

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

          export const useBlockDrag = ({ block, isAnimating, canDrag, onBlockDragOver }) => {
            const ref = useRef(null);
          
            // this makes the block draggable
            const [{ isDragging }, drag] = useDrag({
          Severity: Minor
          Found in app/assets/javascripts/hooks/useBlockDrag.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

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

          export default function articles(state = initialState, action) {
            switch (action.type) {
              case RECEIVE_ARTICLES: {
                const wikis = uniqWith(
                  map(action.data.course.articles, mapWikis),
          Severity: Minor
          Found in app/assets/javascripts/reducers/articles.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

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

          const SpecialUser = ({
            downgradeSpecialUser, // Prop for downgrading special user (renamed from action creator)
            position,
            username = 'Not Defined',
            realname = 'Not Defined',
          Severity: Minor
          Found in app/assets/javascripts/components/settings/views/special_user.jsx - 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

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

            handleCourse(course, isValidProp) {
              if (this.state.shouldRedirect === true) {
                window.location = `/courses/${course.slug}`;
                return this.setState({ shouldRedirect: false });
              }
          Severity: Minor
          Found in app/assets/javascripts/components/course_creator/course_creator.jsx - 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

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

          const CourseWikiList = ({ courses, sort }) => {
            const dispatch = useDispatch();
            if (sort.key) {
              // eslint-disable-next-line no-restricted-syntax
              for (const key of Object.keys(keys)) {

          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 run_update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def run_update
              log_start_of_update 'Daily update tasks are beginning.'
              update_users
              update_commons_uploads
              update_article_data
          Severity: Minor
          Found in lib/data_cycle/daily_update.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 notification has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def notification(survey_id, curr_user=nil)
                if curr_user.nil?
                  # if curr_user is nil, then we haven't preloaded the user's notifications
                  notifications = user.survey_notifications.completed.includes(survey_assignment: :survey)
                else
          Severity: Minor
          Found in config/initializers/surveys.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

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

            const handleKeyDown = async (event) => {
              if (!inputValue) return;
              switch (event.key) {
                case 'Enter':
                case 'Tab':
          app/assets/javascripts/components/course_creator/scoping_methods/petscan_scoping.jsx on lines 36..47

          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

              render() {
                return (
                  <Component
                    {...this.state}
                    {...this.props}
          app/assets/javascripts/components/high_order/expandable.jsx on lines 41..50

          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

              render() {
                return (
                  <Component
                    {...this.state} {...this.props}
                    open={this.open}
          Severity: Major
          Found in app/assets/javascripts/components/high_order/expandable.jsx and 1 other location - About 1 hr to fix
          app/assets/javascripts/components/high_order/popover_expandable.jsx on lines 52..62

          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

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

            const handleKeyDown = async (event) => {
              if (!inputValue) return;
              switch (event.key) {
                case 'Enter':
                case 'Tab':
          app/assets/javascripts/components/course_creator/scoping_methods/pagepile_scoping.jsx on lines 36..47

          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

                {
                  showSortDropdown
                  && (
                  <div className="section-header">
                    <h2>{headerText}</h2>
          Severity: Major
          Found in app/assets/javascripts/components/course/course_list.jsx and 1 other location - About 1 hr to fix
          app/assets/javascripts/components/campaign/campaign_list.jsx on lines 55..60

          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

              test('linkifies by default', () => {
                const md = markdownIt();
                const output = md.render('http://google.com');
                const expected = '<p><a href="http://google.com">http://google.com</a></p>\n';
                expect(output).toBe(expected);
          Severity: Major
          Found in test/utils/markdown_it.spec.js and 1 other location - About 1 hr to fix
          test/utils/markdown_it.spec.js on lines 22..27

          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

              test('allows embedded html by default', () => {
                const md = markdownIt();
                const output = md.render('# h1\n\n<h2>test</h2>\n');
                const expected = '<h1>h1</h1>\n<h2>test</h2>\n';
                expect(output).toBe(expected);
          Severity: Major
          Found in test/utils/markdown_it.spec.js and 1 other location - About 1 hr to fix
          test/utils/markdown_it.spec.js on lines 6..11

          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

                {headerText && (
                  <div className="section-header">
                    <h2>{headerText}</h2>
                    <DropdownSortSelect keys={keys} sortSelect={sortBy}/>
                  </div>
          app/assets/javascripts/components/course/course_list.jsx on lines 9..16

          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

          Function editMode has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const editMode = (e) => {
              e.preventDefault();
              const $parent = $(e.target).parents('.rails_editable');
              $parent.addClass('rails_editable-editing');
              $(e.target).hide();
          Severity: Minor
          Found in app/assets/javascripts/utils/editable.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language