ngduc/node-rem

View on GitHub

Showing 13 of 21 total issues

Function Home has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function Home() {
  const [error, setError] = React.useState<any>(null);
  const [items, setItems] = React.useState<any[] | null>(null);
  const [showCreateModal, setShowCreateModal] = React.useState(false);
  const [newTitle, setNewTitle] = React.useState('');
Severity: Major
Found in ui/src/components/Home/Home.tsx - About 3 hrs to fix

    Function handleJWT has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    const handleJWT = (req: any, res: any, next: any, roles: any) => async (err: any, user: any, info: any) => {
      const error = err || info;
      const logIn: any = Bluebird.promisify(req.logIn);
      const apiError = new APIError({
        message: error ? error.message : 'Unauthorized',
    Severity: Minor
    Found in src/api/middlewares/auth.ts - About 2 hrs 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 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const { action, actionRegister, renderTitle, showError = true } = this.props;
        const { mode, username, password, name, error } = this.state;
    
        let formAction = mode === Mode.LOGIN && action ? action : '';
    Severity: Minor
    Found in ui/src/components/Login/LoginBox.tsx - About 1 hr to fix

      Function findAndGenerateToken has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        async findAndGenerateToken(options: any) {
          const { email, password, refreshObject } = options;
          if (!email) {
            throw new APIError({ message: 'An email is required to generate a token' });
          }
      Severity: Minor
      Found in src/api/models/user.model.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 apiJson has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function apiJson({ req, res, data, model, meta = {}, json = false }: apiJsonTypes) {
        const queryObj = getPageQuery(req.query);
        const metaData = { ...queryObj, ...meta };
      
        if (model) {
      Severity: Minor
      Found in src/api/utils/Utils.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 Login has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export function Login({ onLogin }: { onLogin?: () => void }) {
        const [errorMsg, setErrorMsg] = React.useState('');
        const navigate = useNavigate();
      
        const onSubmit = async (formData: any) => {
      Severity: Minor
      Found in ui/src/components/Login/Login.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 App has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function App() {
        const [loggedInEmail, setLoggedInEmail] = React.useState('');
      
        const refreshEmail = () => {
          const { userEmail } = getLoginData();
      Severity: Minor
      Found in ui/src/App.tsx - About 1 hr to fix

        Function handleJWT has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const handleJWT = (req: any, res: any, next: any, roles: any) => async (err: any, user: any, info: any) => {
          const error = err || info;
          const logIn: any = Bluebird.promisify(req.logIn);
          const apiError = new APIError({
            message: error ? error.message : 'Unauthorized',
        Severity: Minor
        Found in src/api/middlewares/auth.ts - About 1 hr to fix

          Function registerValidSW has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function registerValidSW(swUrl: string, config?: Config) {
            navigator.serviceWorker
              .register(swUrl)
              .then(registration => {
                registration.onupdatefound = () => {
          Severity: Minor
          Found in ui/src/serviceWorker.ts - About 1 hr to fix

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

            export function getSortQuery(sortStr: string, defaultKey = 'createdAt') {
              let arr = [sortStr || defaultKey];
              if (sortStr && sortStr.indexOf(',')) {
                arr = sortStr.split(',');
              }
            Severity: Minor
            Found in src/api/utils/Utils.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 Home has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            export function Home() {
              const [error, setError] = React.useState<any>(null);
              const [items, setItems] = React.useState<any[] | null>(null);
              const [showCreateModal, setShowCreateModal] = React.useState(false);
              const [newTitle, setNewTitle] = React.useState('');
            Severity: Minor
            Found in ui/src/components/Home/Home.tsx - About 35 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

            Avoid too many return statements within this function.
            Open

              return next();
            Severity: Major
            Found in src/api/middlewares/auth.ts - About 30 mins to fix

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

                render() {
                  const { action, actionRegister, renderTitle, showError = true } = this.props;
                  const { mode, username, password, name, error } = this.state;
              
                  let formAction = mode === Mode.LOGIN && action ? action : '';
              Severity: Minor
              Found in ui/src/components/Login/LoginBox.tsx - About 25 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