Showing 5,781 of 10,536 total issues

Function ProfileIntro has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ProfileIntro = () => {
  const [collapsed, setCollapsed] = useState(false);

  return (
    <Card className="mb-3">
Severity: Minor
Found in myems-web/src/components/profile/ProfileIntro.js - About 1 hr to fix

    Function getOption has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getOption = (data, isDark) => {
      const grays = getGrays(isDark);
      return {
        color: data.map(d => d.color),
        tooltip: {
    Severity: Minor
    Found in myems-web/src/components/dashboard-alt/MarketShare.js - About 1 hr to fix

      Function Checkout has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Checkout = () => {
        const { products, shoppingCart, appliedPromo } = useContext(ProductContext);
        const [shippingAddress, setShippingAddress] = useState('address-1');
        const [paymentMethod, setPaymentMethod] = useState('credit-card');
      
      
      Severity: Minor
      Found in myems-web/src/components/e-commerce/Checkout.js - About 1 hr to fix

        Function getOption has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const getOption = (data, isDark) => {
          const grays = getGrays(isDark);
          return {
            color: data.map(d => d.color),
            tooltip: {
        Severity: Minor
        Found in myems-web/src/components/MyEMS/common/SharePie.js - About 1 hr to fix

          Function generate_excel has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def generate_excel(report, space_name, language):
              trans = get_translation(language)
              trans.install()
              _ = trans.gettext
              wb = Workbook()
          Severity: Minor
          Found in myems-api/excelexporters/equipmenttracking.py - About 1 hr to fix

            Function on_get has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def on_get(req, resp, id_):
                    if 'API-KEY' not in req.headers or \
                            not isinstance(req.headers['API-KEY'], str) or \
                            len(str.strip(req.headers['API-KEY'])) == 0:
                        access_control(req)
            Severity: Minor
            Found in myems-api/core/energyflowdiagram.py - About 1 hr to fix

              Function on_put has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def on_put(req, resp, id_):
                      """Handles PUT requests"""
                      admin_control(req)
                      try:
                          raw_json = req.stream.read().decode('utf-8')
              Severity: Minor
              Found in myems-api/core/energystoragecontainer.py - About 1 hr to fix

                Function on_get has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def on_get(req, resp):
                        if 'API-KEY' not in req.headers or \
                                not isinstance(req.headers['API-KEY'], str) or \
                                len(str.strip(req.headers['API-KEY'])) == 0:
                            access_control(req)
                Severity: Minor
                Found in myems-api/core/energyflowdiagram.py - About 1 hr to fix

                  Function on_put has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def on_put(req, resp, id_):
                          """Handles PUT requests"""
                          admin_control(req)
                          try:
                              raw_json = req.stream.read().decode('utf-8')
                  Severity: Minor
                  Found in myems-api/core/rule.py - About 1 hr to fix

                    Function on_get has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def on_get(req, resp, id_):
                            if 'API-KEY' not in req.headers or \
                                    not isinstance(req.headers['API-KEY'], str) or \
                                    len(str.strip(req.headers['API-KEY'])) == 0:
                                access_control(req)
                    Severity: Minor
                    Found in myems-api/core/energyflowdiagram.py - About 1 hr to fix

                      Function on_post has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def on_post(req, resp):
                              """Handles POST requests"""
                              admin_control(req)
                              try:
                                  raw_json = req.stream.read().decode('utf-8')
                      Severity: Minor
                      Found in myems-api/core/offlinemeter.py - About 1 hr to fix

                        Function on_post has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def on_post(req, resp):
                                """Handles POST requests"""
                                admin_control(req)
                                try:
                                    raw_json = req.stream.read().decode('utf-8')
                        Severity: Minor
                        Found in myems-api/core/offlinemeter.py - About 1 hr to fix

                          Function on_put has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def on_put(req, resp, id_, gid):
                                  """Handles PUT requests"""
                                  admin_control(req)
                                  try:
                                      raw_json = req.stream.read().decode('utf-8')
                          Severity: Minor
                          Found in myems-api/core/microgrid.py - About 1 hr to fix

                            Function on_put has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def on_put(req, resp, id_):
                                    """Handles PUT requests"""
                                    admin_control(req)
                                    try:
                                        raw_json = req.stream.read().decode('utf-8')
                            Severity: Minor
                            Found in myems-api/core/virtualmeter.py - About 1 hr to fix

                              Function on_put has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def on_put(req, resp, id_):
                                      """Handles PUT requests"""
                                      admin_control(req)
                                      try:
                                          raw_json = req.stream.read().decode('utf-8')
                              Severity: Minor
                              Found in myems-api/core/tariff.py - About 1 hr to fix

                                Function on_post has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def on_post(req, resp):
                                        """Handles POST requests"""
                                        admin_control(req)
                                        try:
                                            raw_json = req.stream.read().decode('utf-8')
                                Severity: Minor
                                Found in myems-api/core/space.py - About 1 hr to fix

                                  Function on_put has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      def on_put(req, resp):
                                          """Handles PUT requests"""
                                          try:
                                              raw_json = req.stream.read().decode('utf-8')
                                              new_values = json.loads(raw_json)
                                  Severity: Minor
                                  Found in myems-api/core/user.py - About 1 hr to fix

                                    Function on_post has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        def on_post(req, resp):
                                            try:
                                                raw_json = req.stream.read().decode('utf-8')
                                                new_values = json.loads(raw_json)
                                            except Exception as ex:
                                    Severity: Minor
                                    Found in myems-api/core/user.py - About 1 hr to fix

                                      Function min has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        min: function(values){
                                          var min = Number.MAX_VALUE,
                                              i;
                                      
                                          if (values instanceof Array) {
                                      Severity: Minor
                                      Found in myems-admin/js/plugins/jvectormap/jquery-jvectormap-2.0.2.min.js - 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 max has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        max: function(values){
                                          var max = Number.MIN_VALUE,
                                              i;
                                      
                                          if (values instanceof Array) {
                                      Severity: Minor
                                      Found in myems-admin/js/plugins/jvectormap/jquery-jvectormap-2.0.2.min.js - 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language