Showing 390 of 2,206 total issues

Function getMvtExperiments has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getMvtExperiments = (headers, service, derivedPageType) => {
  return Object.entries(headers).reduce((result, [header, content]) => {
    if (header.startsWith('mvt-')) {
      const noMvtPrefixHeader = header.slice(4);

Severity: Minor
Found in src/server/utilities/mvtHeader/getMvtExperiments/index.js - About 1 hr to fix

    Function e has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    function e() {
                        var e = this;
                        this.commandHandlerMap = {
                            setAwsCredentials: function(t) {
                                e.orchestration.setAwsCredentials(t)
    Severity: Minor
    Found in public/vendor/cwr.js - About 1 hr to fix

      Function f has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function f(e) {
                  var t,
                      n,
                      r = [];
                  try {
      Severity: Minor
      Found in public/vendor/cwr.js - About 1 hr to fix

        Function e has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                        function e(e) {
                            var t = e.applyChecksum,
                                n = e.credentials,
                                r = e.region,
                                o = e.service,
        Severity: Minor
        Found in public/vendor/cwr.js - About 1 hr to fix

          Function useCombinedClickTrackerHandler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const useCombinedClickTrackerHandler = eventTrackingData => {
            const blockData = path(['block'], eventTrackingData);
            const linkData = path(['link'], eventTrackingData);
            const optimizely = path(['block', 'optimizely'], eventTrackingData);
            const handleBlockLevelClick = useClickTrackerHandler({

            Function renderContainer has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const renderContainer = (service: Services, pageData: Article) => {
              const toggleState = {
                cpsRecommendations: {
                  enabled: true,
                },
            Severity: Minor
            Found in src/app/components/OptimizelyRecommendations/index.test.tsx - About 1 hr to fix

              Function hashBuffer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                                      }, e.prototype.hashBuffer = function() {
                                          for (var e = this.buffer, t = this.state, n = t[0], o = t[1], i = t[2], s = t[3], a = t[4], c = t[5], u = t[6], l = t[7], d = 0; d < r.BLOCK_SIZE; d++) {
                                              if (d < 16)
                                                  this.temp[d] = (255 & e[4 * d]) << 24 | (255 & e[4 * d + 1]) << 16 | (255 & e[4 * d + 2]) << 8 | 255 & e[4 * d + 3];
                                              else {
              Severity: Minor
              Found in public/vendor/cwr.js - About 1 hr to fix

                Function getServerSideProps has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const getServerSideProps: GetServerSideProps = async context => {
                  const {
                    resolvedUrl,
                    query: { service, variant },
                    req: { headers: reqHeaders },
                Severity: Minor
                Found in ws-nextjs-app/pages/[service]/[[...]].page.tsx - About 1 hr to fix

                  Function Component has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const Component = () => {
                    return (
                      <RequestContextProvider
                        pathname="/pathname"
                        pageType="avEmbeds"
                  Severity: Minor
                  Found in ws-nextjs-app/pages/[service]/av-embeds/avembeds.stories.tsx - About 1 hr to fix

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

                    const generateLinks = (service, env, domain) => {
                      const output = [];
                    
                      const {
                        frontPage,
                    Severity: Minor
                    Found in scripts/releaseInfo/index.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 ordinal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      ordinal: function (number) {
                        var b = number % 10,
                          output =
                            ~~((number % 100) / 10) === 1
                              ? 'th'
                    Severity: Minor
                    Found in src/app/legacy/psammead/psammead-locales/moment/pcm.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 withOptimizelyProvider has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const withOptimizelyProvider = Component => {
                      return props => {
                        const { service } = useContext(ServiceContext);
                        const isStoryBook = process.env.STORYBOOK;
                        const disableOptimizely = isStoryBook;

                    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 avg has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            avg: function (t) {
                              var n = this.histo;
                              if (!this._avg || t) {
                                var o,
                                  i,
                    Severity: Minor
                    Found in src/app/hooks/useImageColour/colorthief.js - About 1 hr to fix

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

                                      this.getCredentialsForIdentity = function(e) {
                                          return i(t, void 0, void 0, (function() {
                                              var t,
                                                  n;
                                              return s(this, (function(r) {
                      Severity: Minor
                      Found in public/vendor/cwr.js - About 1 hr to fix

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

                        const getRouteProps = url => {
                          const matchedRoutes = matchRoutes(routes, url);
                        
                          const route = path([0, 'route'], matchedRoutes);
                          const match = path([0, 'match'], matchedRoutes);
                        Severity: Minor
                        Found in src/app/routes/utils/fetchPageData/utils/getRouteProps/index.js - About 1 hr to fix

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

                          const NielsenAnalytics = () => {
                            const { service, isAmp, pathname } = useContext(RequestContext);
                          
                            // nielsenAnalytics toggle only set up as local toggle at the moment...
                            const { enabled } = useToggle('nielsenAnalytics');
                          Severity: Minor
                          Found in src/app/legacy/containers/NielsenAnalytics/index.jsx - About 1 hr to fix

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

                            const buildRSSMarketingString = href => {
                              const { query, hash } = new Url(href, true);
                            
                              const queryWithParams = hash ? parameteriseHash(hash) : query;
                            
                            
                            Severity: Minor
                            Found in src/app/lib/analyticsUtils/index.js - About 1 hr to fix

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

                              export const getType = (pageType: PageTypes | 'index', shorthand = false) => {
                                switch (pageType) {
                                  case FRONT_PAGE:
                                  case 'index':
                                    return shorthand ? 'IDX' : 'Index';
                              Severity: Minor
                              Found in src/app/components/ChartbeatAnalytics/utils/index.ts - About 1 hr to fix

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

                                const getArticleTopStoryItem = (item: TopStoryItem) => {
                                  const overtypedHeadline = item?.headlines?.overtyped ?? '';
                                  const mainHeadline = item?.headlines?.headline ?? '';
                                  const headlineBlockText =
                                    // @ts-expect-error - nested block structure

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

                                  const dealWithCaretsAndTildes = (versionString, timeJson) => {
                                    const plainVersion = versionString.match(/^[\d.]+$/g);
                                    if (plainVersion) {
                                      return versionString; // if it's just numbers and dots
                                    }
                                  Severity: Minor
                                  Found in scripts/dependencyFreshness.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language