farahat80/react-open-weather

View on GitHub

Showing 5 of 14 total issues

Function useWeatherBit has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const useWeatherBit = (options) => {
  const baseApiUrl = 'https://api.weatherbit.io/v2.0';
  const endpointForecast = `${baseApiUrl}/forecast/daily`;
  const endPointToday = `${baseApiUrl}/current`;
  const [isLoading, setIsLoading] = useState(false);
Severity: Minor
Found in src/js/providers/weatherbit/useWeatherBit.js - About 1 hr to fix

    Function useOpenWeather has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const useOpenWeather = (options) => {
      const endpoint = '//api.openweathermap.org/data/2.5/onecall';
      const [state, dispatch] = useReducer(fetchReducer, initialState);
      const { data, errorMessage } = state;
      const [isLoading, setIsLoading] = useState(false);
    Severity: Minor
    Found in src/js/providers/openweather/useOpenWeather.js - About 1 hr to fix

      Function useVisualCrossing has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const useVisualCrossing = (options) => {
       
        
        const [state, dispatch] = useReducer(fetchReducer, initialState);
        const { data, errorMessage } = state;
      Severity: Minor
      Found in src/js/providers/visualcrossing/useVisualCrossing.js - About 1 hr to fix

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

        export const formatDate = (dte, lang, tz) => {
          if (lang && lang !== 'en') {
            dayjs.locale(lang.replace('_', '-'));
          }
          if (dte && dayjs().isValid(dte)) {
        Severity: Minor
        Found in src/js/providers/visualcrossing/useVisualCrossing.js - 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

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

        const ReactWeather = ({
          unitsLabels,
          showForecast,
          lang,
          data,
        Severity: Minor
        Found in src/js/components/ReactWeather.js - 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