Giter VIP home page Giter VIP logo

Comments (9)

ajayl83 avatar ajayl83 commented on July 3, 2024 2

@rohanKanojia can i pick this up?

from jkube.

ajayl83 avatar ajayl83 commented on July 3, 2024 2

@rohanKanojia this null check is needed , consider when you dont have currDir then you create it as new File(System.getProperty("basedir", ".")) by default then here this parameter is not at all needed, and if in case its null and we dont create default we will end up with NPE on line 53 while we try to find gitfolder without checking null in first place.

so its always good to do defensive programming and its better to validate all preconditions here, let me know what do you think about it?

from jkube.

clarenced avatar clarenced commented on July 3, 2024 2

Hi @rohanKanojia I can help with this issue. :p

from jkube.

rohanKanojia avatar rohanKanojia commented on July 3, 2024 1

@clarenced : Thanks, please see Marc's comment #2711 (comment) for idea of what needs to be done.

from jkube.

clarenced avatar clarenced commented on July 3, 2024 1

After some investigation, the method GitUtil.getGitRepository is called in 2 places :

from GItEnricher (L 54)

try (Repository repository = GitUtil.getGitRepository(getContext().getProjectDirectory())) {
 ...
}

and also from BaseGenerator (L272)

Repository repository = GitUtil.getGitRepository(project.getBaseDirectory());

Is there any situation where project.getBaseDirectory() or getContext().getProjectDirectory() can return null ? If it's not the case, we can safely remove the null-check.

from jkube.

rohanKanojia avatar rohanKanojia commented on July 3, 2024

its always good to do defensive programming and its better to validate all preconditions here

You're right about this. This might be an issue if this utility class is used by users using jkube-kit as a direct dependency. However, at the moment I'm not sure there are users are using jkube-kit as a direct dependency. In our codebase we use it only in two places, JavaProject's base directory seems to be set always from maven and gradle plugin apis.

from jkube.

manusa avatar manusa commented on July 3, 2024

However, at the moment I'm not sure there are users are using jkube-kit as a direct dependency.

Then we might want to throw an exception instead. Objects.requireNonNull or something like that.

from jkube.

ajayl83 avatar ajayl83 commented on July 3, 2024

@manusa yes that would be the ideal way. ok will raise an PR

from jkube.

rohanKanojia avatar rohanKanojia commented on July 3, 2024

@ajayl83 : polite ping, are you still working on this? If not, could you please unassign?

from jkube.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.