Category Archives: Programming

Test coverage on GitLab CI in a rust-cargo project

This topic presents who to setup kcov with cargo to get a test coverage for a cargo project, so I just assume you got kcov working in your Linux distribution and you have a project with source code and tests that you can run. I also assume you have gitlab-ci-multi-runner installed. So I will just quickly present who to configure it to use with GitLab CI to get test coverage badge in your new project.

I use my own CI runner, I’m not using shared runners or docker for it. So it’s pretty straightforward, your configuration will differ a bit.

Continue reading

Rust – get user’s home directory

fn main() {
  let mut path: PathBuf = get_app_dir();
  path.push(".config");
  path.set_file_name("properties");
  path.set_extension("ini");
  let str_path = path.to_str().unwrap();
  if str_path.len() != 0 && path_exists(&path) {
    println!("Path {} exists", str_path);
  }
}
 
fn get_app_dir() -> PathBuf {
    let dir: PathBuf = match env::home_dir() {
        Some(path) => PathBuf::from(path),
        None => PathBuf::from(""),
    };
    dir
}
 
pub fn path_exists(path: &PathBuf) -> bool {
    return Path::new(&path).exists();
}

XXX loves opensource…

…that’s why we published our product on OSI-compatible license! We <3 open-source!

Well, does Microsoft/Google/Apple/Netflix/XXX really love open-source?

No, they don’t. In fact they do more to extinguish open source by fighting them with patent wars, you don’t hear about, developing DRM, you hear about when it’s too late and dropping support for some key-products on open source platforms. Skype on Linux, anyone? Google Drive client on Linux? DRM enabled by default in browsers, anyone?

Continue reading

Setting up SonarQube for Android Gradle project to improve code quality

I’m working on a new Android project which I inherited. Well, I forked it because I didn’t feel welcomed to contribute to the project and I see a lot of places where improvements are needed.

First, I need to improve the codebase. Previous developers didn’t care about any Java coding guidelines from Oracle, Google, CERT or even Android. Some of the problems I have to solve now are:

  • inconsistent style
  • catch (Exception e){}
  • catch(Throwable e){}
  • ArrayList<Object> list = new ArrayList<String>()
  • complex methods – if {switch {for {if {else {}}}}
  • new Thread().start()

To quickly start clean-up and identify those problems, different static code analysis tools can be used; one of them is SonarQube.

Continue reading

Choose GitLab for your next open source project

GitLab.com is a competitor of Github. It’s a service provider for git-based source code repositories that offers much more than it’s bigger brother. In this post I will try to convince you to try it out for your next project.

GitLab is not only a simple git hosting; its features impact the whole development process, the way of contributing to a project, executing and running tests, protecting source code from changes, more and more.

gitlab-logo-square Continue reading