Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

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

  def validate_required_answer
    return unless response.just_submitted? && question.required?

    case question.question_type
    when 'text'
Severity: Minor
Found in app/models/course/survey/answer.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 assessment_submitted has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def assessment_submitted(user, course_user, submission)
    email_enabled = submission.assessment.
                    course.email_enabled(:assessments, :new_submission, submission.assessment.tab.category.id)
    return unless email_enabled.regular || email_enabled.phantom

Severity: Minor
Found in app/notifiers/course/assessment_notifier.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
    result = @post.transaction do
      # Set parent as the topologically last pre-existing post, if it exists.
      # @post is in @topic.posts, so we filter out @post, which has no id yet.
      @post.parent = @topic.posts.ordered_topologically.flatten.select(&:id).last if @topic.posts.length > 1
Severity: Minor
Found in app/controllers/course/discussion/posts_controller.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 invite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def invite(users)
    new_invitations = nil
    existing_invitations = nil
    new_instance_users = nil
    existing_instance_users = nil
Severity: Minor
Found in app/services/instance/user_invitation_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 invite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def invite(users)
    new_invitations = nil
    existing_invitations = nil
    new_course_users = nil
    existing_course_users = nil
Severity: Minor
Found in app/services/course/user_invitation_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 user_enrol_requested_email has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def user_enrol_requested_email(enrol_request)
    ActsAsTenant.without_tenant do
      @course = enrol_request.course
    end
    email_enabled = @course.email_enabled(:users, :new_enrol_request)
Severity: Minor
Found in app/mailers/course/mailer.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 # rubocop:disable Metrics/MethodLength
    if file_is_pdf?
      respond_to do |format|
        if pdf_import_service.save
          format.json { render_success_json t('.success') }
Severity: Minor
Found in app/controllers/course/assessment/question/scribing_controller.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 delete_all_future_stories_personal_times has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def delete_all_future_stories_personal_times(course_user)
    future_story_ids = stories_for(course_user).filter_map do |story|
      story.id if story.personal_time_for(course_user) && story.submitted_at.blank?
    end

Severity: Minor
Found in app/controllers/concerns/course/lesson_plan/stories_concern.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 saveActiveData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    saveActiveData: (
      state,
      action: PayloadAction<{
        conversationId: string;
        snapshotId: string;
Severity: Minor
Found in client/app/bundles/course/assessment/reducers/generation.ts - 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 TextField has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  (props, ref): JSX.Element => {
    const { trims, onPressEnter, onPressEscape, ...textFieldProps } = props;

    const handleChange: ChangeEventHandler<HTMLInputElement> = (e): void => {
      if (trims) {
Severity: Minor
Found in client/app/lib/components/core/fields/TextField.tsx - 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 AssessmentCategoriesManager has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const AssessmentCategoriesManager = (props: Props): JSX.Element => {
  const { categories } = props;
  const { t } = useTranslation();
  const { createCategory, settings } = useAssessmentSettings();

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

const TextResponseForm = <T extends 'new' | 'edit'>(
  props: TextResponseFormProps<T>,
): JSX.Element => {
  const { with: data } = props;

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

const Breadcrumbs = (props: BreadcrumbProps): JSX.Element => {
  const { in: crumbs } = props;

  const { t } = useTranslation();

Severity: Minor
Found in client/app/bundles/course/container/Breadcrumbs/Breadcrumbs.tsx - 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 ActivityCenter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const ActivityCenter = (props: ActivityCenterProps): JSX.Element => {
  const { t } = useTranslation();
  const history = useAppSelector(select('history'));
  const monitoring = useMonitoring();

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

const UsersIndex: FC<Props> = (props) => {
  const { intl } = props;
  const [isLoading, setIsLoading] = useState(false);
  const [filter, setFilter] = useState({ active: false, role: '' });
  const userCounts = useAppSelector(getAdminCounts);
Severity: Minor
Found in client/app/bundles/system/admin/admin/pages/UsersIndex.tsx - 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 ForgotPasswordPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const ForgotPasswordPage = (): JSX.Element => {
  const { t } = useTranslation();

  const [email, setEmail] = useEmailFromAuthPagesContext();

Severity: Minor
Found in client/app/bundles/users/pages/ForgotPasswordPage.tsx - 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 ResendConfirmationEmailPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const ResendConfirmationEmailPage = (): JSX.Element => {
  const { t } = useTranslation();

  const [email, setEmail] = useEmailFromAuthPagesContext();

Severity: Minor
Found in client/app/bundles/users/pages/ResendConfirmationEmailPage.tsx - 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 saveAllGrades has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function saveAllGrades(submissionId, grades, exp, published) {
  const expParam = published ? 'points_awarded' : 'draft_points_awarded';
  const modifiedGrades = grades.map((grade) => ({
    id: grade.id,
    grade: grade.grade,

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

export function fetchSubmission(id, onGetMonitoringSessionId) {
  return (dispatch) => {
    dispatch({ type: actionTypes.FETCH_SUBMISSION_REQUEST });

    return CourseAPI.assessment.submissions
Severity: Minor
Found in client/app/bundles/course/assessment/submission/actions/index.js - About 1 hr to fix

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

const FormToggleField = (props) => {
  const { field, fieldState, disabled, label, renderIf, ...custom } = props;
  const isError = !!fieldState.error;
  if (!renderIf) {
    return null;
Severity: Minor
Found in client/app/lib/components/form/fields/ToggleField.jsx - About 1 hr to fix
Severity
Category
Status
Source
Language