Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Method create_new_submission has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def create_new_submission(new_submission, current_user)
    success = false
    if randomization == 'prepared'
      Course::Assessment::Submission.transaction do
        qbas = question_bundle_assignments.where(user: current_user).lock!
Severity: Minor
Found in app/models/concerns/course/assessment/new_submission_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

Method post_replied has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def post_replied(user, course_user, post)
    course = post.topic.course
    email_enabled = course.email_enabled(:forums, :post_replied)
    return unless email_enabled.regular || email_enabled.phantom

Severity: Minor
Found in app/notifiers/course/forum/post_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 hash_compre_lifted_word has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def hash_compre_lifted_word(question)
    hash = {}
    question.groups.each do |group|
      group.points.each do |point|
        # for all TextResponseComprehensionSolution where solution_type == compre_lifted_word

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

    def self.define_attachment_references_readers(attachable_columns)
      attachable_columns.each do |column|
        email_method_name = "#{column}#{FOR_EMAIL_SUFFIX}"
        unless method_defined?(email_method_name)

Severity: Minor
Found in lib/extensions/attachable/active_record/base.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 buildCrumbsData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const buildCrumbsData = (
  matches: Match[],
  location: Location,
  state: CrumbState,
): CrumbsDataBuilderResult => {
Severity: Minor
Found in client/app/lib/hooks/router/dynamicNest/builder.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

Method create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    result = @submission_question.class.transaction do
      @post.title = @assessment.title
      # Set parent as the topologically last pre-existing post, if it exists.
      @post.parent = last_post_from(@submission_question) if @submission_question.posts.length > 1

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

  def hash_compre_keyword(question)
    hash = {}
    question.groups.each do |group|
      group.points.each do |point|
        # for all TextResponseComprehensionSolution where solution_type == compre_keyword

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

const InlineEditTextField: FC<Props> = (props): JSX.Element | null => {
  const {
    updateValue,
    value,
    disabled,

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

const ForumTopicShow: FC = () => {
  const { t } = useTranslation();
  const { forumId, topicId } = useParams();
  // Need to get the topic Id number below as sometimes, the topicId in the URL is in the form of slug.
  // The topic id number is required to to select the entity from the redux store.
Severity: Minor
Found in client/app/bundles/course/forum/pages/ForumTopicShow/index.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 StudentMarksPerQuestionTable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const StudentMarksPerQuestionTable: FC<Props> = (props) => {
  const { t } = useTranslation();
  const { courseId, assessmentId } = useParams();
  const { includePhantom } = 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 deleteProgrammingFile has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function deleteProgrammingFile(answer, fileId, onDeleteSuccess) {
  const answerId = answer.id;
  const payload = {
    answer: { id: answerId, file_id: fileId },
  };

Function Editor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Editor = (props) => {
  const {
    file,
    fieldName,
    language,

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

  render() {
    const { assessment, isActive } = this.props;

    const tableHeaderColumnFor = (field) => (
      <TableCell style={styles.tableCell}>

Method correctness_hash has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def correctness_hash
    query = CourseUser.find_by_sql(<<-SQL.squish
      SELECT
        id,
        AVG(correctness) AS correctness
Severity: Minor
Found in app/controllers/course/statistics/aggregate_controller.rb - About 1 hr to fix

Function LevelCondition has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LevelCondition = (
  props: AnyConditionProps<LevelConditionData>,
): JSX.Element => {
  const { control, handleSubmit, setError, formState } = useForm({
    defaultValues: props.condition ?? { minimumLevel: 1 },

Function Page has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Page = (props: PageProps): JSX.Element => {
  const { backTo: route } = props;

  const navigate = useNavigate();

Severity: Minor
Found in client/app/lib/components/core/layouts/Page.tsx - About 1 hr to fix

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

  (draft: AchievementsState, action: AchievementsActionType) => {
    switch (action.type) {
      case SAVE_ACHIEVEMENT_LIST: {
        const achievementList = action.achievementList;
        const entityList = achievementList.map((data) => ({
Severity: Minor
Found in client/app/bundles/course/achievement/store.ts - About 1 hr to fix

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

  (draft: LeaderboardState, action: LeaderboardActionType) => {
    switch (action.type) {
      case SAVE_LEADERBOARD_POINTS: {
        const leaderboardPointsList = action.leaderboardByExpPoints;
        saveListToStore(draft.leaderboardPoints, leaderboardPointsList);
Severity: Minor
Found in client/app/bundles/course/leaderboard/store.ts - About 1 hr to fix

Function subscribe has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const subscribe = (
  url: string,
  sessionId: number,
  courseId: number,
  callbacks: HeartbeatChannelCallbacks,
Severity: Minor
Found in client/app/workers/heartbeatChannel.ts - About 1 hr to fix

Function TimelinesStack has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TimelinesStack = (props: TimeBarsProps): JSX.Element => {
  const { for: items, within: timelines } = props;
  const gamified = useAppSelector((state) => state.timelines.gamified);
  const defaultTimelineId = useAppSelector(
    (state) => state.timelines.defaultTimeline,
Severity
Category
Status
Source
Language