Showing 199 of 199 total issues

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

def _oi_scoreboard(is_export, _, tdoc, ranked_tsdocs, udict, dudict, pdict):
  columns = []
  columns.append({'type': 'rank', 'value': _('Rank')})
  columns.append({'type': 'user', 'value': _('User')})
  columns.append({'type': 'display_name', 'value': _('Display Name')})
Severity: Minor
Found in vj4/model/adaptor/contest.py - 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 connection_route has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def connection_route(prefix, name, global_route=False):
  def decorate(conn):
    conn.GLOBAL = global_route
    async def handler(msg, session):
      try:
Severity: Minor
Found in vj4/app.py - 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 render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    return (
      <SplitPane
        defaultSize={this.props.ui.main.size}
        minSize={250}
Severity: Minor
Found in vj4/ui/components/scratchpad/index.js - About 1 hr to fix

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

    const page = new NamedPage('homework_main', () => {
      // Homework Calendar
      if (Context.docs) {
        const events = Context.docs.map(doc => ({
          beginAt: doc.begin_at * 1000,
    Severity: Minor
    Found in vj4/ui/pages/homework_main.page.js - About 1 hr to fix

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

        def __init__(self):
          middlewares = []
          if options.sentry_dsn:
            middlewares.append(SentryMiddleware({
              'dsn': options.sentry_dsn,
      Severity: Minor
      Found in vj4/app.py - About 1 hr to fix

        Function handleClickRemoveSelected has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async function handleClickRemoveSelected() {
            const selectedUsers = ensureAndGetSelectedUsers();
            if (selectedUsers === null) {
              return;
            }
        Severity: Minor
        Found in vj4/ui/pages/domain_manage_user.page.js - About 1 hr to fix

          Function touch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function touch(mtime) {
          
            async function touchFile(file) {
              const fd = await fs.open(file.path, 'a');
              try {
          Severity: Minor
          Found in scripts/build/plugins/gulpTouch.js - About 1 hr to fix

            Function onCommentClickEdit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function onCommentClickEdit(mode, ev) {
              const $evTarget = $(ev.currentTarget);
            
              if (CommentBox.get($evTarget)) {
                CommentBox
            Severity: Minor
            Found in vj4/ui/components/discussion/comments.page.js - About 1 hr to fix

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

                render() {
                  const { data } = this.props;
                  const submitAt = parseMongoId(data._id).timestamp * 1000;
                  return (
                    <tr onClick={ev => this.handleRowClick(ev, data._id)}>
              Severity: Minor
              Found in vj4/ui/components/scratchpad/ScratchpadRecordsRowContainer.js - About 1 hr to fix

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

                  case 'SCRATCHPAD_UI_CHANGE_SIZE': {
                    const { uiElement, size } = action.payload;
                    return {
                      ...state,
                      [uiElement]: {
                Severity: Minor
                Found in vj4/ui/components/scratchpad/reducers/ui.js and 1 other location - About 55 mins to fix
                vj4/ui/components/scratchpad/reducers/ui.js on lines 29..38

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

                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

                  case 'SCRATCHPAD_UI_SET_VISIBILITY': {
                    const { uiElement, visibility } = action.payload;
                    return {
                      ...state,
                      [uiElement]: {
                Severity: Minor
                Found in vj4/ui/components/scratchpad/reducers/ui.js and 1 other location - About 55 mins to fix
                vj4/ui/components/scratchpad/reducers/ui.js on lines 19..28

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

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

                  constructor(name, autoload, afterLoading, beforeLoading) {
                    if (process.env.NODE_ENV !== 'production') {
                      if (typeof name !== 'string' && !(name instanceof Array)) {
                        // eslint-disable-next-line quotes
                        throw new Error(`'name' should be a string or [string]`);
                Severity: Minor
                Found in vj4/ui/misc/PageLoader.js - 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 highlightBlocks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  highlightBlocks: $dom => {
                    $dom.find('pre code').get().forEach(code => {
                      const $pre = $(code).parent();
                      $pre.addClass('syntax-hl');
                      if ($pre.closest('[data-syntax-hl-show-line-number]')) {
                Severity: Minor
                Found in vj4/ui/components/highlighter/prismjs.js - 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 default has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function (env = {}) {
                  function eslintLoader() {
                    return {
                      loader: 'eslint-loader',
                      options: {
                Severity: Minor
                Found in scripts/build/config/webpack.js - 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

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

                          {
                            props: this.props.ui.pretest,
                            onChange: size => this.handleChangeSize('pretest', size),
                            element: <ScratchpadPretest key="pretest" />,
                          },
                Severity: Minor
                Found in vj4/ui/components/scratchpad/index.js and 1 other location - About 55 mins to fix
                vj4/ui/components/scratchpad/index.js on lines 89..93

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

                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

                          {
                            props: this.props.ui.records,
                            onChange: size => this.handleChangeSize('records', size),
                            element: <ScratchpadRecords key="records" />,
                          },
                Severity: Minor
                Found in vj4/ui/components/scratchpad/index.js and 1 other location - About 55 mins to fix
                vj4/ui/components/scratchpad/index.js on lines 84..88

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

                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

                          if (bannerSpan.banner.endTrunc) {
                            $banner.addClass('is-trunc-end');
                          } else if (bannerSpan.banner.endSnap) {
                            $banner.addClass('is-snap-end');
                          }
                Severity: Minor
                Found in vj4/ui/components/calendar/index.js and 1 other location - About 55 mins to fix
                vj4/ui/components/calendar/index.js on lines 147..151

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

                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

                          if (bannerSpan.banner.beginTrunc) {
                            $banner.addClass('is-trunc-begin');
                          } else if (bannerSpan.banner.beginSnap) {
                            $banner.addClass('is-snap-begin');
                          }
                Severity: Minor
                Found in vj4/ui/components/calendar/index.js and 1 other location - About 55 mins to fix
                vj4/ui/components/calendar/index.js on lines 152..156

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

                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 _acm_scoreboard has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def _acm_scoreboard(is_export, _, tdoc, ranked_tsdocs, udict, dudict, pdict):
                Severity: Major
                Found in vj4/model/adaptor/contest.py - About 50 mins to fix

                  Function get_user_in_problem_multi has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def get_user_in_problem_multi(uid: int, domain_id: str, pid: document.convert_doc_id,
                  Severity: Major
                  Found in vj4/model/record.py - About 50 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language