WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

Function render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    let description;
      if (this.props.source === 'pileid') {
        description = (
          <p>
Severity: Minor
Found in app/assets/javascripts/components/categories/add_category_button.jsx - About 55 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 set_revisions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def set_revisions
    @new_revisions = {}
    @course.revisions.includes(:wiki, :article, :user).map do |edit|
      # Skip if the Article record is missing
      next unless edit.article
Severity: Minor
Found in lib/analytics/course_revisions_csv_builder.rb - About 55 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

Function AssignCell has a Cognitive Complexity of 9 (exceeds 5 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 55 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

Function ThisWeek has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const ThisWeek = ({ course, weeks, current_user }) => {
  let weekIndex;
  let thisWeekMeetings;
  let weekMeetings;
  let week;
Severity: Minor
Found in app/assets/javascripts/components/overview/this_week.jsx - About 55 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

Function MyArticlesContainer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const MyArticlesContainer = ({ current_user }) => {
  const dispatch = useDispatch();

  const assignments = useSelector(state => state.assignments.assignments);
  const course = useSelector(state => state.course);

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

  def create_assignment
    set_clean_title
    set_article_from_database
    check_wiki_edu_discouraged_article
    import_article_from_wiki unless @article
Severity: Minor
Found in lib/assignment_manager.rb - About 55 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 answer_meets_alert_conditions? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def answer_meets_alert_conditions?(answer)
    conditions = answer.question.alert_conditions

    if conditions[:equals]
      return true if answer.answer_text == conditions[:equals]
Severity: Minor
Found in lib/alerts/survey_response_alert_manager.rb - About 55 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

Function option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    option: (styles, { isDisabled, isFocused, isSelected }) => {
      let backgroundColor;
      let color;
      if (isDisabled) {
      backgroundColor = null;
Severity: Minor
Found in app/assets/javascripts/styles/sort_select.js - About 45 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

Function getWikiMap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const getWikiMap = (revisions) => {
  const wikiMap = new Map();
  for (const revision of revisions) {
    if (supportsPageAssessments(revision.wiki) || isSupportedORESWiki(revision.wiki)
    ) {
Severity: Minor
Found in app/assets/javascripts/utils/revision_utils.js - About 45 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

Function updateCourseDates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  updateCourseDates(prevCourse, valueKey, value) {
    const updatedCourse = Object.assign({}, prevCourse); // clone the course
    updatedCourse[valueKey] = value;
    // Just return with the new value if it doesn't pass validation
    // or if it it lacks timeline dates
Severity: Minor
Found in app/assets/javascripts/utils/course_date_utils.js - About 45 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

Function range has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function* range(left, right, inclusive) {
  const ascending = left < right;

  let endOfRange;
  if (!inclusive) {
Severity: Minor
Found in app/assets/javascripts/utils/course_date_utils.js - About 45 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

Function claimAssignment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const claimAssignment = (assignment, successNotification) => (dispatch) => {
  return claimAssignmentPromise(assignment)
    .then((resp) => {
      if (resp.assignment) {
        if (successNotification) { dispatch(addNotification(successNotification)); }
Severity: Minor
Found in app/assets/javascripts/actions/assignment_actions.js - About 45 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

Function searchForPages has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  async searchForPages(wiki, search_term, namespace, map=(el)=>el, depth, limit=10){
Severity: Minor
Found in app/assets/javascripts/utils/api.js - About 45 mins to fix

    Function createNewsContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const createNewsContent = (newsContent, post = false) => async (dispatch, getState) => {
      if (post) {
        try {
          // If `post` is true, create news on the server
          const newsDetails = await API.createNews(getState().news.create_news);
    Severity: Minor
    Found in app/assets/javascripts/actions/news_action.js - About 45 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

    Function fetchCourseScopedRevisions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const fetchCourseScopedRevisions = (course, limit) => async (dispatch, getState) => {
      const state = getState();
      const users = state.users.users.filter(user => user.role === STUDENT_ROLE);
    
      dispatch({ type: COURSE_SCOPED_REVISIONS_LOADING });
    Severity: Minor
    Found in app/assets/javascripts/actions/revisions_actions.js - About 45 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

    Function option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      option: (styles, { isDisabled, isFocused, isSelected }) => {
        let backgroundColor;
        let color;
        if (isDisabled) {
          backgroundColor = null;
    Severity: Minor
    Found in app/assets/javascripts/styles/single_select.js - About 45 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

    Function NamespaceSelect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const NamespaceSelect = (props) => {
      const [selectedNamespaces, setSelectedNamespaces] = useState([]);
      const [options, setOptions] = useState([]);
    
      useEffect(() => {
    Severity: Minor
    Found in app/assets/javascripts/components/common/namespace_select.jsx - About 45 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

    Function Revision has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const Revision = ({ revision, index, wikidataLabel, course, setSelectedIndex, lastIndex, selectedIndex }) => {
      const ratingClass = `rating ${revision.rating}`;
      const ratingMobileClass = `${ratingClass} tablet-only`;
      const formattedTitle = CourseUtils.formattedArticleTitle({ title: revision.title, project: revision.wiki.project, language: revision.wiki.language }, course.home_wiki, wikidataLabel);
      const subtitle = wikidataLabel ? `(${CourseUtils.removeNamespace(revision.title)})` : '';
    Severity: Minor
    Found in app/assets/javascripts/components/revisions/revision.jsx - About 45 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

    Function selectDay has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      selectDay(day) {
        let exceptions;
        if (!this.inrange(day)) { return; }
        const { course } = this.props;
        if (course.day_exceptions === undefined) {
    Severity: Minor
    Found in app/assets/javascripts/components/common/calendar.jsx - About 45 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

    Function CourseForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const CourseForm = (props) => {
      const handleWikiChange = (wiki) => {
        const home_wiki = wiki.value;
        const prev_wiki = { ...props.course.home_wiki };
        const wikis = CourseUtils.normalizeWikis(
    Severity: Minor
    Found in app/assets/javascripts/components/course_creator/course_form.jsx - About 45 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