WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

Function NewAccountButton has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const NewAccountButton = ({ course, passcode, currentUser }) => {
  const [showModal, setShowModal] = useState(false);
  const [disabled, setDisabled] = useState(false);
  const [isHovered, setIsHovered] = useState(false);

Severity: Minor
Found in app/assets/javascripts/components/enroll/new_account_button.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 Category has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const Category = ({ course, category, remove, editable }) => {
  let removeButton;
  if (editable) {
    removeButton = (
      <button className="button pull-right small danger" onClick={remove}>
Severity: Minor
Found in app/assets/javascripts/components/categories/category.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 Actions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const Actions = ({
  article, assignment, courseSlug, current_user, isComplete, username,
  isEnglishWikipedia, isClassroomProgram, unassign, course
}) => {
  if (isComplete) {

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

  def create_alerts
    @courses.each do |course|
      next if Alert.exists?(course_id: course.id,
                            type: 'ContinuedCourseActivityAlert',
                            resolved: false)
Severity: Minor
Found in lib/alerts/continued_course_activity_alert_manager.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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def create
      @question_group = Rapidfire::QuestionGroup.new(question_group_params)
      if @question_group.save
        respond_to do |format|
          if params.key?(:redirect_to_edit)
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

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

  def try_to_process_notifications(method)
    SurveyNotification.active.email_enabled.each do |notification|
      @notification = notification
      # Sending an email and updating the record returns true.
      # When no email needs to be sent, the email methods return nil.
Severity: Minor
Found in lib/data_cycle/survey_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 sender has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def sender
      message = messages.first
      return {} unless message
      
      user = message.sender if message
Severity: Minor
Found in config/initializers/ticket_dispenser.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

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

export const fetchKeywordResults = (keyword, wiki, offset = 0, continueResults = false) => (dispatch, getState) => {
  if (!continueResults) {
    dispatch({
      type: INITIATE_SEARCH
    });
Severity: Minor
Found in app/assets/javascripts/actions/article_finder_action.js - About 1 hr to fix

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

      [getSpecialUsers, getStaffUsers], (specialUsers, staffUsers) => {
        // Compare staff users of a course with classroom program manager and
        // wiki expert users. Make a list of all Special Users objects with
        // required information. Mark any user in the list as already_selected
        // if they have already been selected as a staff user, to prevent them
    Severity: Minor
    Found in app/assets/javascripts/selectors/index.js - About 1 hr to fix

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

        trainingSelector() {
          const MultiValueRemove = (props) => {
            return (
              <components.MultiValueRemove {...props}>
                <components.CrossIcon aria-hidden={false} aria-label={'Remove Module'} />

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

        const DefaultCampaignForm = (props) => {
          const [default_campaign_slug, setDefault_campaign_slug] = useState(null);
        
          const handleChange = (key, value) => {
            setDefault_campaign_slug(value);

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

          render() {
            const { is_open } = this.props;
            const editRow = (
              <tr className="edit">
                <td>

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

              const answersList = () => {
                const answers = answers_data;
                const list = answers.map((answer) => {
                  const { course, data: answerData, user, sentiment: answerSentiment } = answer;
                  const courseTitle = course === null ? null : course.title;
            Severity: Minor
            Found in app/assets/javascripts/surveys/components/TextResults.jsx - About 1 hr to fix

              Method base_salesforce_fields has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def base_salesforce_fields
                  {
                    Name: @course.title,
                    Course_Page__c: @course.url,
                    Course_End_Date__c: @course.end.strftime('%Y-%m-%d'),
              Severity: Minor
              Found in app/services/push_course_to_salesforce.rb - About 1 hr to fix

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

                export const AssignCell = (props) => {
                  const {
                    assignments, course, current_user,
                    editable, isStudentsPage, prefix, student
                  } = props;
                Severity: Minor
                Found in app/assets/javascripts/components/common/AssignCell/AssignCell.jsx - About 1 hr to fix

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

                            <button
                              className="tooltip-trigger cancel--note admin-focus-highlight"
                              aria-label={I18n.t('notes.admin.aria_label.note_edit_cancel_button_focused', { title: note.title })}
                              onClick={() => onNotesEditCancelButtonClickHandler()}
                            >
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 93..102
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 118..127
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 161..170

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

                  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

                                    <button
                                      className="tooltip-trigger admin-focus-highlight"
                                      aria-label={I18n.t('notes.admin.aria_label.note_delete_button_focused', { title: note.title })}
                                      onClick={() => deleteNote(note.id)}
                                    >
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 93..102
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 104..113
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 118..127

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

                  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

                      <Student
                        assignments={assignments}
                        course={course}
                        current_user={current_user}
                        editable={editAssignments}
                  app/assets/javascripts/components/common/AssignCell/AssignButton.jsx on lines 438..446
                  app/assets/javascripts/components/overview/my_articles/components/Categories/List/Assignment/ProgressTracker/Step/Step.jsx on lines 22..30
                  app/assets/javascripts/components/overview/my_articles/containers/index.jsx on lines 60..68

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

                  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

                            <NewAssignmentInput
                              language={language}
                              project={project}
                              title={title}
                              assign={onSubmit}
                  app/assets/javascripts/components/overview/my_articles/components/Categories/List/Assignment/ProgressTracker/Step/Step.jsx on lines 22..30
                  app/assets/javascripts/components/overview/my_articles/containers/index.jsx on lines 60..68
                  app/assets/javascripts/components/students/shared/StudentList/StudentRow.jsx on lines 10..18

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

                  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

                            <button
                              className="tooltip-trigger admin-focus-highlight"
                              aria-label={I18n.t('notes.admin.aria_label.note_edit_button_focused', { title: note.title })}
                              onClick={() => onNotesEditButtonClickHandler(note.id, note.title, note.text)}
                            >
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 104..113
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 118..127
                  app/assets/javascripts/components/admin_notes/notes_row.jsx on lines 161..170

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language